Skip to content

Commit d80bd98

Browse files
added docs for the channel data source
1 parent af7638a commit d80bd98

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelDataSource.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,53 @@
44

55
import StreamChat
66

7+
/// Data source providing the chat messages.
78
protocol MessagesDataSource: AnyObject {
89

10+
/// Called when the messages are updated.
11+
///
12+
/// - Parameters:
13+
/// - channelDataSource, the channel's data source.
14+
/// - messages, the collection of updated messages.
915
func dataSource(
1016
channelDataSource: ChannelDataSource,
1117
didUpdateMessages messages: LazyCachedMapCollection<ChatMessage>
1218
)
1319

20+
/// Called when the channel is updated.
21+
/// - Parameters:
22+
/// - channelDataSource: the channel's data source.
23+
/// - channel: the updated channel.
24+
/// - channelController: the channel's controller.
1425
func dataSource(
1526
channelDataSource: ChannelDataSource,
1627
didUpdateChannel channel: EntityChange<ChatChannel>,
1728
channelController: ChatChannelController
1829
)
1930
}
2031

32+
/// The data source for the channel.
2133
protocol ChannelDataSource: AnyObject {
2234

35+
/// Delegate implementing the `MessagesDataSource`.
2336
var delegate: MessagesDataSource? { get set }
2437

38+
/// List of the messages.
2539
var messages: LazyCachedMapCollection<ChatMessage> { get }
2640

41+
/// Loads the previous messages.
42+
/// - Parameters:
43+
/// - messageId: the id of the last received message.
44+
/// - limit: the max number of messages to be retrieved.
45+
/// - completion: called when the messages are loaded.
2746
func loadPreviousMessages(
2847
before messageId: MessageId?,
2948
limit: Int,
3049
completion: ((Error?) -> Void)?
3150
)
3251
}
3352

53+
/// Implementation of `ChannelDataSource`. Loads the messages of the channel.
3454
class ChatChannelDataSource: ChannelDataSource, ChatChannelControllerDelegate {
3555

3656
let controller: ChatChannelController
@@ -78,6 +98,7 @@ class ChatChannelDataSource: ChannelDataSource, ChatChannelControllerDelegate {
7898
}
7999
}
80100

101+
/// Implementation of the `ChannelDataSource`. Loads the messages in a reply thread.
81102
class MessageThreadDataSource: ChannelDataSource, ChatMessageControllerDelegate {
82103

83104
let channelController: ChatChannelController

0 commit comments

Comments
 (0)