Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat: update docs for async room get #2299

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions content/chat/rooms/index.textile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ blang[react].
</aside>

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

```[react]
Expand Down Expand Up @@ -70,21 +70,23 @@ blang[javascript].
const reactions = {};
const occupancy = {};
const typing = {timeoutMs: 5000};
const room = chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy});
const room = await chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy});
```

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

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

Or configure each feature using your own values:

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

Note that any unresolved promises from @rooms.get()@ will be rejected when @rooms.release()@ is called.

blang[react].

Enable each feature using its associated option. The details of the options available to each feature are documented on their respective pages:
Expand All @@ -104,6 +106,8 @@ Releasing a room may be optional for many applications. If you have multiple tra
blang[javascript].
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.

Note that any unresolved promises from @rooms.get()@ will be rejected when @rooms.release()@ is called.

```[javascript]
await rooms.release('basketball-stream');
```
Expand Down Expand Up @@ -165,7 +169,7 @@ Monitoring the status of a room enables you to track its lifecycle and react acc
A room can have any of the following statuses:

|_. Status |_. Description |
| initializing | The library is initializing the room. |
| initializing | The library is initializing the room. This status is only used for React when the room has not yet resolved. |
| initialized | The room has been initialized, but no attach has been attempted yet. |
| 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. |
| attached | An attach has succeeded. In the attached status a client can publish and subscribe to messages, and enter the presence set. |
Expand Down