Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-arg variants of presence operations #186

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading