Skip to content

Commit d59832d

Browse files
authored
chat: update docs for async room get (#2299)
1 parent 2d603e8 commit d59832d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

content/chat/rooms/index.textile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ blang[react].
2828
</aside>
2929

3030
```[javascript]
31-
const room = chatClient.rooms.get('basketball-stream', RoomOptionsDefaults);
31+
const room = await chatClient.rooms.get('basketball-stream', RoomOptionsDefaults);
3232
```
3333

3434
```[react]
@@ -70,21 +70,23 @@ blang[javascript].
7070
const reactions = {};
7171
const occupancy = {};
7272
const typing = {timeoutMs: 5000};
73-
const room = chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy});
73+
const room = await chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy});
7474
```
7575

7676
You can also use the @RoomOptionsDefaults@ property for each @RoomOption@ to configure whether the default settings should be used:
7777

7878
```[javascript]
79-
const room = chatClient.rooms.get('basketball-stream', {presence: RoomOptionsDefaults.presence});
79+
const room = await chatClient.rooms.get('basketball-stream', {presence: RoomOptionsDefaults.presence});
8080
```
8181

8282
Or configure each feature using your own values:
8383

8484
```[javascript]
85-
const room = chatClient.rooms.get('basketball-stream', {typing: {timeoutMs: 5000}});
85+
const room = await chatClient.rooms.get('basketball-stream', {typing: {timeoutMs: 5000}});
8686
```
8787

88+
Note that any unresolved promises from @rooms.get()@ will be rejected when @rooms.release()@ is called.
89+
8890
blang[react].
8991

9092
Enable each feature using its associated option. The details of the options available to each feature are documented on their respective pages:
@@ -104,6 +106,8 @@ Releasing a room may be optional for many applications. If you have multiple tra
104106
blang[javascript].
105107
Once "@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Rooms.html#release has been called, the room will be unusable and a new instance will need to be created using "@rooms.get()@":#create if you want to reuse it.
106108

109+
Note that any unresolved promises from @rooms.get()@ will be rejected when @rooms.release()@ is called.
110+
107111
```[javascript]
108112
await rooms.release('basketball-stream');
109113
```
@@ -165,7 +169,7 @@ Monitoring the status of a room enables you to track its lifecycle and react acc
165169
A room can have any of the following statuses:
166170

167171
|_. Status |_. Description |
168-
| initializing | The library is initializing the room. |
172+
| initializing | The library is initializing the room. This status is only used for React when the room has not yet resolved. |
169173
| initialized | The room has been initialized, but no attach has been attempted yet. |
170174
| attaching | An attach has been initiated by sending a request to Ably. This is a transient status and will be followed either by a transition to attached, suspended, or failed. |
171175
| attached | An attach has succeeded. In the attached status a client can publish and subscribe to messages, and enter the presence set. |

0 commit comments

Comments
 (0)