Skip to content

Commit

Permalink
change async room.sid to method
Browse files Browse the repository at this point in the history
This way ObjC can be supported
  • Loading branch information
hiroshihorie committed Jan 9, 2024
1 parent aed9406 commit 7ae1aa5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Sources/LiveKit/Core/Room.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ public class Room: NSObject, ObservableObject, Loggable {
/// Server assigned id of the Room.
public var sid: Sid? { _state.sid }

// Work-around error: Property with 'throws' or 'async' is not representable in Objective-C
/// Server assigned id of the Room. **async** version of ``Room/sid``.
/// Example: `let sid = try await room.asyncSid`
public var asyncSid: Sid {
get async throws {
try await _sidCompleter.wait()
}
/// Server assigned id of the Room. *async* version of ``Room/sid``.
@objc
public func sid() async throws -> Sid {
try await _sidCompleter.wait()
}

@objc
Expand Down Expand Up @@ -140,7 +137,7 @@ public class Room: NSObject, ObservableObject, Loggable {

var _state: StateSync<State>

private let _sidCompleter = AsyncCompleter<Sid>(label: "sid", timeOut: .sid)
private let _sidCompleter = AsyncCompleter<Sid>(label: "sid", defaultTimeOut: .sid)

// MARK: Objective-C Support

Expand Down

0 comments on commit 7ae1aa5

Please sign in to comment.