Skip to content
Draft
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
37 changes: 37 additions & 0 deletions src/pages/docs/chat/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,40 @@ The `logLevel` sets the verbosity of logs that will be output by the SDK. The fo
| `error` | A given operation has failed and cannot be automatically recovered. The error may threaten the continuity of operation. |
| `silent` | No logging will be performed. |

## Dispose of the client <a id="dispose"/>

Use the <If lang="javascript,react">[`dispose()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ChatClient.html#dispose)</If><If lang="swift">[`dispose()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/chatclient/dispose%28%29)</If><If lang="kotlin,jetpack">[`dispose()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-chat-client/dispose.html)</If> method to release all resources associated with the chat client when you are done using it:

<Code>
```javascript
await chatClient.dispose();
```

```react
await chatClient.dispose();
```

```swift
await chatClient.dispose()
```

```kotlin
chatClient.dispose()
```

```jetpack
chatClient.dispose()
```
</Code>

Calling `dispose()` will:
- Release all rooms managed by the client
- Clean up connection listeners and timers
- Free internal resources
Comment on lines +360 to +362
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Release all rooms managed by the client
- Clean up connection listeners and timers
- Free internal resources
- Release all rooms managed by the client.
- Clean up connection listeners and timers.
- Free internal resources.


After calling `dispose()`, the client should not be used. Attempting to get a room after dispose has been called will throw an error. This method is idempotent, so calling it multiple times has no additional effect.

<Aside data-type='note'>
The `dispose()` method does not close the underlying Ably Realtime connection, as that connection is owned by the Pub/Sub client that was passed to the Chat client during instantiation. To close the connection, call `close()` on the Pub/Sub client directly.
</Aside>