File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed
Sources/AblyLiveObjects/Public Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,23 @@ clientOptions.plugins = [.liveObjects: AblyLiveObjects.Plugin.self]
2525
2626let realtime = ARTRealtime (options : clientOptions)
2727
28- // You can now access LiveObjects functionality via a channel's `objects` property:
29- let channel = realtime.channels .get (" myChannel" )
28+ // Fetch a channel, specifying the `.objectPublish` and `.objectSubscribe` modes
29+ let channelOptions = ARTRealtimeChannelOptions ()
30+ channelOptions.modes = [.objectPublish , .objectSubscribe ]
31+ let channel = realtime.channels .get (" myChannel" , options : channelOptions)
32+
33+ // Attach the channel
34+ try await withCheckedThrowingContinuation { (continuation : CheckedContinuation< Void , Error > ) in
35+ channel.attach { error in
36+ if let error {
37+ continuation.resume (throwing : error)
38+ } else {
39+ continuation.resume ()
40+ }
41+ }
42+ }
43+
44+ // You can now access LiveObjects functionality via the channel's `objects` property:
3045let rootObject = try await channel.objects .getRoot ()
3146// …and so on
3247```
Original file line number Diff line number Diff line change @@ -15,8 +15,23 @@ import ObjectiveC.NSObject
1515///
1616/// let realtime = ARTRealtime(options: clientOptions)
1717///
18- /// // You can now access LiveObjects functionality via a channel's `objects` property:
19- /// let channel = realtime.channels.get("myChannel")
18+ /// // Fetch a channel, specifying the `.objectPublish` and `.objectSubscribe` modes
19+ /// let channelOptions = ARTRealtimeChannelOptions()
20+ /// channelOptions.modes = [.objectPublish, .objectSubscribe]
21+ /// let channel = realtime.channels.get("myChannel", options: channelOptions)
22+ ///
23+ /// // Attach the channel
24+ /// try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
25+ /// channel.attach { error in
26+ /// if let error {
27+ /// continuation.resume(throwing: error)
28+ /// } else {
29+ /// continuation.resume()
30+ /// }
31+ /// }
32+ /// }
33+ ///
34+ /// // You can now access LiveObjects functionality via the channel's `objects` property:
2035/// let rootObject = try await channel.objects.getRoot()
2136/// // …and so on
2237/// ```
You can’t perform that action at this time.
0 commit comments