Added mention of StreamExt trait extension. (#886)

This commit is contained in:
marcerhans authored and GitHub committed 2023-03-15 09:08:29 -05:00
1 parent 059f6b18db
commit f0c9dadf77
1 file changed
+8
+8
View File
@@ -92,6 +92,8 @@ With Coroutines, we can centralize our async logic. The `rx` parameter is an Cha
```rust ```rust
use futures_util::stream::StreamExt;
enum ProfileUpdate { enum ProfileUpdate {
SetUsername(String), SetUsername(String),
SetAge(i32) SetAge(i32)
@@ -117,6 +119,10 @@ cx.render(rsx!{
}) })
``` ```
> Note: In order to use/run the `rx.next().await` statement you will need to extend the [`Stream`] trait (used by [`UnboundedReceiver`]) by adding 'futures_util' as a dependency to your project and adding the `use futures_util::stream::StreamExt;`.
For sufficiently complex apps, we could build a bunch of different useful "services" that loop on channels to update the app. For sufficiently complex apps, we could build a bunch of different useful "services" that loop on channels to update the app.
```rust ```rust
@@ -164,6 +170,8 @@ fn Banner(cx: Scope) -> Element {
Now, in our sync service, we can structure our state however we want. We only need to update the view values when ready. Now, in our sync service, we can structure our state however we want. We only need to update the view values when ready.
```rust ```rust
use futures_util::stream::StreamExt;
enum SyncAction { enum SyncAction {
SetUsername(String), SetUsername(String),
} }