You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/reactnative/state-and-offline-support/state-overview.mdx
+70-4Lines changed: 70 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,12 +248,12 @@ To disconnect a user you can call `disconnect` on the client.
248
248
awaitclient.disconnectUser();
249
249
```
250
250
251
-
## Thread and ThreadManager
251
+
## POJO
252
252
253
-
With the new [threads feature](../guides/custom-thread-list.mdx) we've decided to refresh our state management and moved to a subscribable POJO with selector based system to make developer experience better when it came to rendering information provided by our `StreamChat` client.
253
+
With a few of our new features, we've decided to refresh our state management and moved to a subscribable POJO with selector based system to make developer experience better when it came to rendering information provided by our `StreamChat` client.
254
254
255
255
:::note
256
-
This change is currently only available within `StreamChat.threads` but will be reused across the whole SDK later on.
256
+
This change is currently only available within `StreamChat.threads`, `StreamChat.poll` and `StreamChat.polls` but will be reused across the whole SDK later on.
For the ease of use - the React SDK comes with the appropriate state access hook which wraps `StateStore.subscribeWithSelector` API for the React-based applications.
352
+
For the ease of use - the React Native SDK comes with the appropriate state access hook which wraps `StateStore.subscribeWithSelector` API for the React-based applications.
One of the feature that follows the new POJO style of state management is the [threads feature](../guides/custom-thread-list.mdx).
377
+
378
+
It provides a reactive state for both a single `Thread` (through a reactive `threadInstance`) and a list of threads (through `StreamChat.threads`).
379
+
380
+
Both states can be accessed through `selector`s as outlined in the examples above.
381
+
382
+
## Poll and PollManager
383
+
384
+
Our new polls feature also follows the new POJO style of state management. A `poll` in itself is something that needs to be linked to a `message` in order for it to work. When a poll is created, the only way to make it visible to the users is to send it as a message. This `message` needs to have a `poll_id` attached to it and preferably no text.
385
+
386
+
You can access each `poll`'s reactive state by getting it by ID using `StreamChat.polls.fromState(<poll-id>)`.
387
+
388
+
:::note
389
+
Please keep in mind that `message.poll` is not going to be reactive, but will rather contain the raw `poll` data as returned by our backend.
390
+
:::
391
+
392
+
### Utility hooks
393
+
394
+
The React Native SDK provides 2 utility hooks to help with consuming the `poll` state. They can be found listed below:
Similarly to the `threads` feature, one can also directly use `useStateStore` and access `StreamChat.polls.fromState(<poll-id>).state` through custom `selector`s.
400
+
401
+
:::note
402
+
Both `usePollStateStore` and `usePollState` can only be used in children of a [`PollContext`](./contexts/poll-context.mdx). This impediment does not exist however on `useStateStore`.
403
+
:::
404
+
405
+
Due to this, all `poll` related components within the SDK are self-wrapped within a `PollContext` and require `message` and `poll` as mandatory props.
0 commit comments