Skip to content

Commit

Permalink
Addressed rooms feedback not touching lines from another PR (#2300) t…
Browse files Browse the repository at this point in the history
…o avoid merge conflicts.
  • Loading branch information
maratal committed Dec 1, 2024
1 parent 0761952 commit 8b6ada5
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions content/chat/rooms/index.textile
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ blang[react].
<p>If the value changes between re-renders then the room will be discarded and recreated with the new options. To prevent a parent component re-render causing the @ChatRoomProvider@ to re-render, either memoize or provide a stable reference to your room options.</p>
</aside>

blang[javascript].

blang[swift].

When you create or retrieve a room using @rooms.get()@, you need to choose which additional chat features you want enabled for that room. This is configured by passing a "@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat_js.RoomOptions.html object as the second argument. In addition to setting which features are enabled, @RoomOptions@ also configures the properties of the associated features, such as the timeout period for typing indicators.

blang[javascript].
blang[javascript,swift].
When you create or retrieve a room using @rooms.get()@, you need to choose which additional chat features you want enabled for that room. This is configured by passing a <span lang="javascript>"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat_js.RoomOptions.html</span><span lang="swift">"@RoomOptions@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomOptions.html</span> object as the second argument. In addition to setting which features are enabled, @RoomOptions@ also configures the properties of the associated features, such as the timeout period for typing indicators.

```[javascript]
const presence = {enter: false};
Expand All @@ -81,6 +76,15 @@ blang[javascript].
const room = chatClient.rooms.get('basketball-stream', {presence, reactions, typing, occupancy});
```

```[swift]
let presence = PresenceOptions(enter: false)
let typing = TypingOptions(timeout: 5.0) // seconds
// using defaults for reactions and occupancy
let options = RoomOptions(presence: presence, typing: typing, reactions: nil, occupancy: nil)
let room = try await chatClient.rooms.get(roomID: "basketball-stream", options: options)
```

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

```[javascript]
Expand All @@ -92,41 +96,40 @@ blang[javascript].
```[javascript]
const room = chatClient.rooms.get('basketball-stream', {typing: {timeoutMs: 5000}});
```

Enable each feature using its associated option. The details of the options available to each feature are documented on their respective pages:

blang[react,swift].

Enable each feature using its associated option. The details of the options available to each feature are documented on their respective pages:

blang[javascript].
| Feature | @RoomOption@ | Default settings |
| "Presence":/chat/rooms/presence | @presence@ | @RoomOptionsDefaults.presence@ |
| "Occupancy":/chat/rooms/occupancy | @occupancy@ | @RoomOptionsDefaults.occupancy@ |
| "Typing indicators":/chat/rooms/typing | @typing@ | @RoomOptionsDefaults.typing@ |
| "Room reactions":/chat/rooms/reactions | @reactions@ | @RoomOptionsDefaults.reactions@ |

blang[react].

blang[swift].

```[swift]
let presence = PresenceOptions(enter: false)
let typing = TypingOptions(timeout: 5.0) // seconds
let options = RoomOptions(presence: presence, typing: typing, reactions: nil, occupancy: nil)
let room = try await chatClient.rooms.get(roomID: "basketball-stream", options: options)
```
| Feature | @RoomOption@ | Default settings |
| "Presence":/chat/rooms/presence | @presence@ | @PresenceOptions()@ |
| "Occupancy":/chat/rooms/occupancy | @occupancy@ | @OccupancyOptions()@ |
| "Typing indicators":/chat/rooms/typing | @typing@ | @TypingOptions()@ |
| "Room reactions":/chat/rooms/reactions | @reactions@ | @RoomReactionsOptions()@ |

h3(#release). Release a room

Releasing a room allows the underlying resources to be garbage collected or released.

Releasing a room may be optional for many applications. If you have multiple transient rooms, such as in the case of a 1:1 support chat, then it is may be more beneficial.
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.

blang[javascript].
blang[javascript,swift].
Once <span lang="javascript>"@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat_js.Rooms.html#release</span><span lang="swift">"@rooms.release()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Rooms.html#release</span> 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.

```[javascript]
await rooms.release('basketball-stream');
```

```[swift]
_ = try await rooms.release(roomID: "basketball-stream")
try await rooms.release(roomID: "basketball-stream")
```

blang[react].
Expand Down

0 comments on commit 8b6ada5

Please sign in to comment.