Skip to content

Commit 58a0d2e

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

File tree

8 files changed

+36
-20
lines changed

8 files changed

+36
-20
lines changed

Sources/Entities/Channel+AsyncAwait.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ 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+
/// Returns the complete list of monitored channels whenever any one of them changes, excluding any that were removed.
1921
///
2022
/// - Parameter channels: Collection containing the channels to watch for updates
2123
/// - Returns: An asynchronous stream that produces updates when any item in the `channels` collection is updated
@@ -473,7 +475,7 @@ public extension Channel {
473475

474476
/// Receives updates on a single ``Channel`` object.
475477
///
476-
/// - Returns: An asynchronous stream that produces updates when the current ``Channel`` is edited or removed.
478+
/// - Returns: An asynchronous stream that produces updates when the current ``Channel`` is edited or `nil` if the channel was removed.
477479
func streamUpdates() -> AsyncStream<ChatType.ChatChannelType?> {
478480
AsyncStream { continuation in
479481
let autoCloseable = streamUpdates {

Sources/Entities/Channel.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ 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+
/// Returns the complete list of monitored channels whenever any one of them changes, excluding any that were removed.
3840
///
3941
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4042
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
4143
///
4244
/// - Parameters:
4345
/// - channels: Collection containing the channels to watch for updates
44-
/// - callback: Defines the custom behavior to be executed when detecting channels changes
46+
/// - callback: A closure to be executed when detecting channel changes
4547
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
4648
static func streamUpdatesOn(
4749
channels: [Self],
@@ -387,7 +389,7 @@ public protocol Channel: CustomStringConvertible {
387389
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
388390
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
389391
///
390-
/// - Parameter callback: Function that takes a single Channel object. It defines the custom behavior to be executed when detecting channel changes
392+
/// - Parameter callback: A closure to be executed when detecting channel changes. Takes a single Channel object or `nil` if the channel was removed
391393
/// - Returns: ``AutoCloseable`` interface that lets you stop receiving channel-related updates (objects events) and clean up resources by invoking the `close()` method
392394
func streamUpdates(
393395
callback: @escaping ((ChatType.ChatChannelType)?) -> Void

Sources/Entities/Membership+AsyncAwait.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ 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+
/// Returns the complete list of monitored memberships whenever any one of them changes, excluding any that were removed.
1921
///
2022
/// - Parameter memberships: Collection containing the ``Membership`` to watch for updates
2123
/// - Returns: An asynchronous stream that produces updates when any item in the `memberships` collection is updated
@@ -97,9 +99,9 @@ public extension Membership {
9799
}
98100
}
99101

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

Sources/Entities/Membership.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ 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+
/// Returns the complete list of monitored memberships whenever any one of them changes, excluding any that were removed.
3840
///
3941
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4042
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
4143
///
4244
/// - Parameters:
4345
/// - memberships: Collection containing the ``Membership`` to watch for updates
44-
/// - callback: Defines the custom behavior to be executed when detecting membership changes
46+
/// - callback: A closure to be executed when detecting membership changes
4547
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
4648
static func streamUpdatesOn(
4749
memberships: [Self],
@@ -94,12 +96,12 @@ public protocol Membership: CustomStringConvertible {
9496
completion: ((Swift.Result<UInt64?, Error>) -> Void)?
9597
)
9698

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

Sources/Entities/Message+AsyncAwait.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ 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+
/// Returns the complete list of monitored messages whenever any one of them changes, excluding any that were removed.
1921
///
2022
/// - Parameter messages: A collection of ``Message`` objects for which you want to get updates on changed messages
2123
/// - Returns: An asynchronous stream that produces updates when any item in the `messages` collection is updated

Sources/Entities/Message.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ 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+
/// Returns the complete list of monitored messages whenever any one of them changes, excluding any that were removed.
6567
///
6668
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
6769
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
6870
///
6971
/// - Parameters:
7072
/// - messages: A collection of ``Message`` objects for which you want to get updates on changed messages
71-
/// - callback: Function that takes a collection of ``Message`` objects. It defines the custom behavior to be executed when detecting message or message reaction changes
73+
/// - callback: A closure to be executed when detecting message or message reaction changes
7274
/// - Returns: Interface that lets you stop receiving message-related updates by invoking the `close()` method
7375
static func streamUpdatesOn(
7476
messages: [Self],

Sources/Entities/User+AsyncAwait.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ 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+
/// Returns the complete list of monitored users whenever any one of them changes, excluding any that were removed.
1921
///
2022
/// - Parameters:
2123
/// - users: Collection containing the users to watch for updates
@@ -179,7 +181,7 @@ public extension User {
179181

180182
/// Receives updates on a single User object.
181183
///
182-
/// - Returns: An asynchronous stream that produces updates when the current ``User`` is edited or removed.
184+
/// - Returns: An asynchronous stream that produces updates when the current ``User`` is edited or `nil` if the user was removed.
183185
func streamUpdates() -> AsyncStream<ChatType.ChatUserType?> {
184186
AsyncStream { continuation in
185187
let autoCloseable = streamUpdates {

Sources/Entities/User.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ 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+
/// Returns the complete list of monitored users whenever any one of them changes, excluding any that were removed.
4648
///
4749
/// - Important: Keep a strong reference to the returned ``AutoCloseable`` object as long as you want to receive updates. If ``AutoCloseable`` is deallocated,
4850
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
4951
///
5052
/// - Parameters:
5153
/// - users: Collection containing the users to watch for updates
52-
/// - callback: Defines the custom behavior to be executed when detecting users changes
54+
/// - callback: A closure to be executed when detecting user changes
5355
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
5456
static func streamUpdatesOn(
5557
users: [ChatType.ChatUserType],
@@ -156,7 +158,7 @@ public protocol User: CustomStringConvertible {
156158
/// the stream will be canceled, and no further items will be produced. You can also stop receiving updates manually by calling ``AutoCloseable/close()``.
157159
///
158160
/// - Parameters:
159-
/// - callback: A function that is triggered whenever the user's information are changed (added, edited, or removed)
161+
/// - callback: A closure to be executed when detecting user changes. Takes a User object or `nil` if the user was removed
160162
/// - Returns: An ``AutoCloseable`` that you can use to stop receiving objects events by invoking its ``AutoCloseable/close()`` method
161163
func streamUpdates(
162164
callback: @escaping ((ChatType.ChatUserType?) -> Void)

0 commit comments

Comments
 (0)