You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chat: add Jetpack Compose support to documentation
- Added examples showcasing the use of Jetpack Compose APIs in the chat SDK.
- Updated documentation to include Jetpack Compose methods such as `collectAsPagingMessagesState()`, `collectAsCurrentlyTyping()`, `collectAsStatus()`, and others.
- Extended sections with Jetpack Compose-specific code snippets for message reactions, typing events, room management, and more.
Copy file name to clipboardExpand all lines: src/pages/docs/chat/connect.mdx
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,10 @@ Use the <If lang="javascript">[`status`](https://sdk.ably.com/builds/ably/ably-c
28
28
Use the [`currentStatus`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseChatConnectionResponse.html#currentStatus) property returned in the response of the [`useChatConnection`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat-react.useChatConnection.html) hook to check which status a connection is currently in:
29
29
</If>
30
30
31
+
<Iflang="jetpack">
32
+
Use the [`collectAsStatus()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/jetpack/chat-extensions-compose/com.ably.chat.extensions.compose/collect-as-status.html) composable function to observe the connection status as a State:
val connectionStatus by chatClient.connection.collectAsStatus()
70
+
71
+
Text("Connection status: $connectionStatus")
72
+
}
73
+
```
59
74
</Code>
60
75
61
76
<Iflang="react">
@@ -84,6 +99,10 @@ Listeners can also be registered to monitor the changes in connection status. An
84
99
Use the <Iflang="javascript">[`connection.onStatusChange()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Connection.html#onStatusChange)</If><Iflang="swift">[`connection.onStatusChange()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/connection/onstatuschange%28%29-76t7)</If><Iflang="kotlin">[`connection.status.onStatusChange()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-connection/on-status-change.html)</If> method to register a listener for status change updates:
85
100
</If>
86
101
102
+
<Iflang="jetpack">
103
+
In Jetpack Compose, you can use [`collectAsStatus()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/jetpack/chat-extensions-compose/com.ably.chat.extensions.compose/collect-as-status.html) to observe status changes reactively:
104
+
</If>
105
+
87
106
<Code>
88
107
```javascript
89
108
const { off } =chatClient.connection.onStatusChange((change) =>console.log(change));
Copy file name to clipboardExpand all lines: src/pages/docs/chat/rooms/history.mdx
+60-2Lines changed: 60 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,11 @@ The history feature enables users to retrieve messages that have been previously
8
8
## Retrieve previously sent messages <aid="history"/>
9
9
10
10
<Iflang="javascript,swift,kotlin">
11
-
Use the <Iflang="javascript">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#history)</If><Iflang="swift">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messages/history(withparams:))</If><Iflang="kotlin">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages/history.html)</If> method to retrieve messages that have been previously sent to a room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
11
+
Use the <Iflang="javascript">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#history)</If><Iflang="swift">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messages/history(withparams:))</If><Iflang="kotlin">[`messages.history()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages/history.html)</If><Iflang="jetpack">[`collectAsPagingMessagesState()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/jetpack/chat-extensions-compose/com.ably.chat.extensions.compose/collect-as-paging-messages-state.html)</If> method to retrieve messages that have been previously sent to a room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
12
+
</If>
13
+
14
+
<Iflang="jetpack">
15
+
Use the [`collectAsPagingMessagesState()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/jetpack/chat-extensions-compose/com.ably.chat.extensions.compose/collect-as-paging-messages-state.html) method to retrieve messages that have been previously sent to a room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
12
16
</If>
13
17
14
18
<Iflang="react">
@@ -71,6 +75,28 @@ while (historicalMessages.hasNext()) {
val pagingMessagesState by room.messages.collectAsPagingMessagesState(
89
+
orderBy = OrderBy.NewestFirst
90
+
)
91
+
92
+
LazyColumn {
93
+
items(pagingMessagesState.messages.size) { index ->
94
+
val message = pagingMessagesState.messages[index]
95
+
Text("Message: ${message.text}")
96
+
}
97
+
}
98
+
}
99
+
```
74
100
</Code>
75
101
76
102
The following optional parameters can be passed when retrieving previously sent messages:
@@ -90,6 +116,10 @@ Users can also retrieve historical messages that were sent to a room before the
90
116
Use the <Iflang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><Iflang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29))</If><Iflang="kotlin">[`getPreviousMessages()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/get-previous-messages.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
91
117
</If>
92
118
119
+
<Iflang="jetpack">
120
+
Use the [`getPreviousMessages()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/get-previous-messages.html) function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
121
+
</If>
122
+
93
123
<Iflang="react">
94
124
Use the [`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseMessagesResponse.html#historyBeforeSubscribe) method available from the response of the `useMessages` hook to only retrieve messages that were received before the listener subscribed to the room. As long as a defined value is provided for the listener, and there are no message discontinuities, `historyBeforeSubscribe()` will return messages from the same point across component renders. If the listener becomes undefined, the subscription to messages will be removed. If you subsequently redefine the listener then `historyBeforeSubscribe()` will return messages from the new point of subscription. This returns a paginated response, which can be queried further to retrieve the next set of messages.
95
125
</If>
@@ -157,7 +187,7 @@ val subscription = room.messages.subscribe {
157
187
println("New message received")
158
188
}
159
189
160
-
var historicalMessages = subscription.historyBeforeSubscribe(limit =50)
190
+
var historicalMessages = subscription.getPreviousMessages(limit =50)
161
191
println(historicalMessages.items.toString())
162
192
163
193
while (historicalMessages.hasNext()) {
@@ -167,6 +197,34 @@ while (historicalMessages.hasNext()) {
0 commit comments