-
Notifications
You must be signed in to change notification settings - Fork 45
chat: add Jetpack Compose support to documentation #2991
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
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Added examples showcasing the use of Jetpack Compose APIs in the chat SDK. - Updated documentation to include Jetpack Compose methods such as `collectAsPagingMessagesState()`, `collectAsCurrentlyTyping()`, `collectAsStatus()`, and others. - Extended sections with Jetpack Compose-specific code snippets for message reactions, typing events, room management, and more.
d33713d to
3d7feab
Compare
| label: 'Kotlin', | ||
| syntaxHighlighterKey: 'kotlin', | ||
| }, | ||
| jetpack: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these as a fixup so that it shows up in docs - could you source an icon for Jetpack so it shows in the language selector?
| ``` | ||
|
|
||
| ```jetpack | ||
| import com.ably.chat.ChatClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation on the code examples are different between Kotlin and Jetpack in many places (despite being the same code) - can we fix this?
| </Code> | ||
| </If> | ||
|
|
||
| ## Handle connection discontinuity <a id="discontinuity"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have discontinuityAsFlow - should that be mentioned here?
| </If> | ||
|
|
||
| <If lang="jetpack"> | ||
| For Jetpack Compose, use the [`collectAsPagingMessagesState()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/jetpack/chat-extensions-compose/com.ably.chat.extensions.compose/collect-as-paging-messages-state.html) composable function to observe messages with automatic pagination support. Alternatively, you can use [`messages.subscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages/subscribe.html) for a simple subscription: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid saying "For Jetpack Compose", as the language selector filters all this out. It should just be "Use the..."
| <If lang="javascript,kotlin"> | ||
| Use the `unsubscribe()` function returned in the `subscribe()` response to remove a chat message listener: | ||
| <If lang="javascript,kotlin,jetpack"> | ||
| Use the `unsubscribe()` function returned in the `subscribe()` response to remove a chat message listener<If lang="jetpack">. When using Jetpack Compose's `collectAsPagingMessagesState()`, lifecycle and cleanup are handled automatically</If>: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this extra sentence, because someone using jetpack won't be expecting to use it? So we just say:
"collectAsPagingMessagesState() handles lifecycle and cleanup automatically"
|
|
||
| ### Occupancy event structure | ||
|
|
||
| The following is the structure of an occupancy event: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to fix this for Kotlin and Swift
|
|
||
| <If lang="javascript,kotlin"> | ||
| Use the `unsubscribe()` function returned in the `subscribe()` response to remove a room occupancy listener: | ||
| <If lang="javascript,kotlin,jetpack"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto re Jetpack having its own if block rather than tacking on the end of kotlin
| ```jetpack | ||
| // Jetpack Compose handles cleanup automatically | ||
| // When using subscribe directly: | ||
| val (unsubscribe) = room.occupancy.subscribe { event -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto re whether we should be encouraging manual subscription with jetpack
|
|
||
| Note that if sending two identical reactions of type `Distinct`, the second one will be accepted and broadcast as a raw reaction, but it will be ignored in the summary (aggregate). Similarly, when removing a reaction that doesn't exist (of any type), the operation will be accepted and broadcast as a raw reaction, but it will have no effect on the summary. | ||
|
|
||
| ### Configure the default reaction type <a id="default-type"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a jetpack
|
|
||
| ## Messages and reactions <a id="messages-and-reactions"/> | ||
|
|
||
| The `Message` object contains a `reactions` property which is an object that looks like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs Kotlin+Swift section
Description
collectAsPagingMessagesState(),collectAsCurrentlyTyping(),collectAsStatus(), and others.Checklist