Skip to content

Commit

Permalink
Add no-arg variants of presence operations
Browse files Browse the repository at this point in the history
I missed these when copying across the public API from JS in 20e7f5f.
The correct behaviour of these variants is not specified by the chat
spec, but this will behaviour will do for now; I’ll think about it a bit
more in #178.
  • Loading branch information
lawrence-forooghian committed Dec 9, 2024
1 parent ee6194b commit 4ee16bd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/AblyChat/Presence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public protocol Presence: AnyObject, Sendable, EmitsDiscontinuities {
func get(params: PresenceQuery) async throws -> [PresenceMember]
func isUserPresent(clientID: String) async throws -> Bool
func enter(data: PresenceData?) async throws
func enter() async throws
func update(data: PresenceData?) async throws
func update() async throws
func leave(data: PresenceData?) async throws
func leave() async throws
func subscribe(event: PresenceEventType, bufferingPolicy: BufferingPolicy) async -> Subscription<PresenceEvent>
/// Same as calling ``subscribe(event:bufferingPolicy:)`` with ``BufferingPolicy.unbounded``.
///
Expand All @@ -94,6 +97,20 @@ public protocol Presence: AnyObject, Sendable, EmitsDiscontinuities {
func subscribe(events: [PresenceEventType]) async -> Subscription<PresenceEvent>
}

public extension Presence {
func enter() async throws {
try await enter(data: nil)
}

func update() async throws {
try await update(data: nil)
}

func leave() async throws {
try await leave(data: nil)
}
}

public extension Presence {
func subscribe(event: PresenceEventType) async -> Subscription<PresenceEvent> {
await subscribe(event: event, bufferingPolicy: .unbounded)
Expand Down

0 comments on commit 4ee16bd

Please sign in to comment.