Skip to content

Commit 6e09639

Browse files
committed
chat: update room status and connection status
per CHADR-062, we renamed some types and restrucured the room status / connection handlers. This change updates the docs accordingly.
1 parent d59832d commit 6e09639

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

content/chat/connect.textile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ A connection can have any of the following statuses:
2222
| failed | This status is entered if the SDK encounters a failure condition that it cannot recover from. This may be a fatal connection error received from the Ably service, such as an attempt to connect with an incorrect API key, or some local terminal error, such as that the token in use has expired and the SDK does not have any way to renew it. |
2323

2424
blang[javascript].
25+
<<<<<<< HEAD
2526
Use the "@current@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ConnectionStatus.html#current property to check which status a connection is currently in:
27+
=======
28+
Use the "@status@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat_js.Connection.html#status property to check which status a connection is currently in:
29+
>>>>>>> 0d6cc60d6 (chat: update room status and connection status)
2630

2731
blang[react].
2832
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:
2933

3034
```[javascript]
31-
const connectionStatus = chatClient.connection.status.current;
35+
const connectionStatus = chatClient.connection.status;
36+
37+
// The error related to the current status
38+
const error = chatClient.connection.error;
3239
```
3340

3441
```[react]
@@ -64,13 +71,17 @@ blang[react].
6471
blang[javascript].
6572

6673
blang[javascript].
74+
<<<<<<< HEAD
6775
Use the "@connection.status.onChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ConnectionStatus.html#onChange method to register a listener for status change updates:
76+
=======
77+
Use the "@connection.onStatusChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat_js.Connection.html#onStatusChange method to register a listener for status change updates:
78+
>>>>>>> 0d6cc60d6 (chat: update room status and connection status)
6879

6980
blang[react].
7081
Listeners can also be registered to monitor the changes in connection status. Any hooks that take an optional listener to monitor their events, such as typing indicator events in the @useTyping@ hook, can also register a status change listener. Changing the value provided for a listener will cause the previously registered listener instance to stop receiving events. All messages will be received by exactly one listener.
7182

7283
```[javascript]
73-
const { off } = chatClient.connection.status.onStatusChange((change) => console.log(change));
84+
const { off } = chatClient.connection.onStatusChange((change) => console.log(change));
7485
```
7586

7687
```[react]
@@ -93,10 +104,10 @@ blang[javascript].
93104
off();
94105
```
95106

96-
Use the "@connection.status.offAll()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ConnectionStatus.html#offAll method to remove all connection status listeners:
107+
Use the "@connection.offAllStatusChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Connection.html#offAllStatusChange method to remove all connection status listeners:
97108

98109
```[javascript]
99-
chatClient.connection.status.offAll();
110+
chatClient.connection.offAllStatusChange();
100111
```
101112

102113
blang[react].

content/chat/rooms/index.textile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,16 @@ A room can have any of the following statuses:
179179
| failed | An indefinite failure condition. This status is entered if an error has been received from Ably, such as an attempt to attach without the necessary access rights. |
180180

181181
blang[javascript].
182-
Use the "@current@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomStatus.html#current property to check which status a room is currently in:
182+
Use the "@status@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html#status property to check which status a room is currently in:
183183

184184
blang[react].
185185
Use the @roomStatus@ property to view the current "@Room@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html status changes. The @roomError@ property is its associated error. Any hooks that take an optional listener have these properties available in their response, such as @useMessages@ or @useTyping@. It is more common that you will monitor the room status in the specific feature hooks rather than needing to use @useRoom@. These events are related to the room instance of the nearest "@ChatRoomProvider@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat-react.ChatRoomProvider.html. For example, with the @useMessages@ hook:
186186

187187
```[javascript]
188-
const currentStatus = room.status.current
188+
const currentStatus = room.status;
189+
190+
// The error related to the current room status
191+
const currentError = room.error;
189192
```
190193

191194
```[react]
@@ -210,7 +213,7 @@ const MyComponent = () => {
210213
blang[javascript].
211214
You can also subscribe to room status updates by registering a listener. An event will be emitted whenever the status of the room changes.
212215

213-
Use the "@room.status.onChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomStatus.html#onChange method in a room to register a listener for status change updates:
216+
Use the "@room.onStatusChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html#onStatusChange method in a room to register a listener for status change updates:
214217

215218
```[javascript]
216219
const { off } = room.onStatusChange((change) =>
@@ -223,10 +226,10 @@ blang[javascript].
223226
off();
224227
```
225228

226-
Use the "@room.status.offAll()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomStatus.html#offAll method to remove all room status listeners in a room:
229+
Use the "@room.offAllStatusChange()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html#offAllStatusChange method to remove all room status listeners in a room:
227230

228231
```[javascript]
229-
room.status.offAll();
232+
room.offAllStatusChange();
230233
```
231234

232235
blang[react].

0 commit comments

Comments
 (0)