Skip to content

Commit edefaa7

Browse files
committed
Clarify streamUpdatesOn and streamUpdates behavior
1 parent 78f75d8 commit edefaa7

File tree

8 files changed

+40
-16
lines changed

8 files changed

+40
-16
lines changed

Sources/Entities/Channel+AsyncAwait.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import PubNubSDK
1515
/// Extension providing `async-await` support for ``Channel``.
1616
///
1717
public extension Channel {
18-
/// Receive updates when specific channels are added, edited or removed.
18+
/// Receive updates when specific channels are updated or removed.
19+
///
20+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
21+
/// If an object is removed, the returning list will not contain it.
1922
///
2023
/// - Parameter channels: Collection containing the channels to watch for updates
2124
/// - Returns: An asynchronous stream that produces updates when any item in the `channels` collection is updated
@@ -473,7 +476,7 @@ public extension Channel {
473476

474477
/// Receives updates on a single ``Channel`` object.
475478
///
476-
/// - Returns: An asynchronous stream that produces updates when the current ``Channel`` is edited or removed.
479+
/// - Returns: An asynchronous stream that produces updates when the current ``Channel`` is edited or `nil` if the channel was removed.
477480
func streamUpdates() -> AsyncStream<ChatType.ChatChannelType?> {
478481
AsyncStream { continuation in
479482
let autoCloseable = streamUpdates {

Sources/Entities/Channel.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public protocol Channel: CustomStringConvertible {
3434
/// Represents the type of the given ``Channel``
3535
var type: ChannelType? { get }
3636

37-
/// Receive updates when specific channels are added, edited or removed.
37+
/// Receive updates when specific channels are updated or removed.
38+
///
39+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
40+
/// If an object is removed, the returning list will not contain it.
3841
///
3942
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4043
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
@@ -387,7 +390,7 @@ public protocol Channel: CustomStringConvertible {
387390
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
388391
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
389392
///
390-
/// - Parameter callback: Function that takes a single Channel object. It defines the custom behavior to be executed when detecting channel changes
393+
/// - Parameter callback: A closure to be executed when detecting channel changes. Takes a single Channel object or `nil` if the channel was removed
391394
/// - Returns: ``AutoCloseable`` interface that lets you stop receiving channel-related updates (objects events) and clean up resources by invoking the `close()` method
392395
func streamUpdates(
393396
callback: @escaping ((ChatType.ChatChannelType)?) -> Void

Sources/Entities/Membership+AsyncAwait.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import PubNubSDK
1515
/// Extension providing `async-await` support for ``Membership``.
1616
///
1717
public extension Membership {
18-
/// Receive updates when specific memberships are added, edited or removed.
18+
/// Receive updates when specific memberships are updated or removed.
19+
///
20+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
21+
/// If an object is removed, the returning list will not contain it.
1922
///
2023
/// - Parameter memberships: Collection containing the ``Membership`` to watch for updates
2124
/// - Returns: An asynchronous stream that produces updates when any item in the `memberships` collection is updated
@@ -97,9 +100,9 @@ public extension Membership {
97100
}
98101
}
99102

100-
/// You can receive updates when specific user-channel Membership object(s) are added, edited, or removed.
103+
/// You can receive updates when this user-channel Membership object is updated or removed.
101104
///
102-
/// - Returns: An asynchronous stream that produces updates when the current ``Membership`` is edited or removed.
105+
/// - Returns: An asynchronous stream that produces updates when the current ``Membership`` is updated or `nil` if the membership was removed.
103106
func streamUpdates() -> AsyncStream<ChatType.ChatMembershipType?> {
104107
AsyncStream { continuation in
105108
let autoCloseable = streamUpdates {

Sources/Entities/Membership.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public protocol Membership: CustomStringConvertible {
3434
/// Timetoken of the last message a user read on a given channel
3535
var lastReadMessageTimetoken: Timetoken? { get }
3636

37-
/// Receive updates when specific memberships are added, edited or removed.
37+
/// Receive updates when specific memberships are updated or removed.
38+
///
39+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
40+
/// If an object is removed, the returning list will not contain it.
3841
///
3942
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4043
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
@@ -94,12 +97,12 @@ public protocol Membership: CustomStringConvertible {
9497
completion: ((Swift.Result<UInt64?, Error>) -> Void)?
9598
)
9699

97-
/// You can receive updates when specific user-channel Membership object(s) are added, edited, or removed.
100+
/// You can receive updates when this user-channel Membership object is updated or removed.
98101
///
99102
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
100103
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
101104
///
102-
/// - Parameter callback: Defines the custom behavior to be executed when detecting membership changes
105+
/// - Parameter callback: A closure to be executed when detecting membership changes. Takes a Membership object or `nil` if the membership was removed
103106
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
104107
func streamUpdates(
105108
callback: @escaping ((ChatType.ChatMembershipType?) -> Void)

Sources/Entities/Message+AsyncAwait.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import PubNubSDK
1515
/// Extension providing `async-await` support for ``Message``.
1616
///
1717
public extension Message {
18-
/// Receive updates when specific messages and related message reactions are added, edited, or removed.
18+
/// Receive updates when specific messages and related message reactions are updated or removed.
19+
///
20+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
21+
/// If an object is removed, the returning list will not contain it.
1922
///
2023
/// - Parameter messages: A collection of ``Message`` objects for which you want to get updates on changed messages
2124
/// - Returns: An asynchronous stream that produces updates when any item in the `messages` collection is updated

Sources/Entities/Message.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public protocol Message: CustomStringConvertible {
6161
/// Error associated with the message, if any
6262
var error: Error? { get }
6363

64-
/// Receive updates when specific messages and related message reactions are added, edited, or removed.
64+
/// Receive updates when specific messages and related message reactions are updated or removed.
65+
///
66+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
67+
/// If an object is removed, the returning list will not contain it.
6568
///
6669
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
6770
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.

Sources/Entities/User+AsyncAwait.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import PubNubSDK
1515
/// Extension providing `async-await` support for ``User``.
1616
///
1717
public extension User {
18-
/// Receive updates when specific users are added, edited or removed.
18+
/// Receive updates when specific users are updated or removed.
19+
///
20+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
21+
/// If an object is removed, the returning list will not contain it.
1922
///
2023
/// - Parameters:
2124
/// - users: Collection containing the users to watch for updates
@@ -179,7 +182,7 @@ public extension User {
179182

180183
/// Receives updates on a single User object.
181184
///
182-
/// - Returns: An asynchronous stream that produces updates when the current ``User`` is edited or removed.
185+
/// - Returns: An asynchronous stream that produces updates when the current ``User`` is edited or `nil` if the user was removed.
183186
func streamUpdates() -> AsyncStream<ChatType.ChatUserType?> {
184187
AsyncStream { continuation in
185188
let autoCloseable = streamUpdates {

Sources/Entities/User.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public protocol User: CustomStringConvertible {
4242
/// Indicates whether the user is currently (at the time of obtaining this ``User`` object) active
4343
var active: Bool { get }
4444

45-
/// Receive updates when specific users are added, edited or removed.
45+
/// Receive updates when specific users are updated or removed.
46+
///
47+
/// This method takes an array of fixed items and returns the full snapshot, except when an object is removed.
48+
/// If an object is removed, the returning list will not contain it.
4649
///
4750
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4851
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
@@ -156,7 +159,7 @@ public protocol User: CustomStringConvertible {
156159
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
157160
///
158161
/// - Parameters:
159-
/// - callback: A function that is triggered whenever the user's information are changed (added, edited, or removed)
162+
/// - callback: A closure to be executed when detecting user changes. Takes a User object or `nil` if the user was removed
160163
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
161164
func streamUpdates(
162165
callback: @escaping ((ChatType.ChatUserType?) -> Void)

0 commit comments

Comments
 (0)