diff options
| author | 2025-02-11 01:27:51 +0100 | |
|---|---|---|
| committer | 2025-02-11 01:27:51 +0100 | |
| commit | f37d068af52700570f863960c3432df85a244a7c (patch) | |
| tree | 464cbe91785db3c1c9924e2f2d1df6ce008aa914 /futures/src/backend | |
| parent | 05618ea9b39048ca905918682e99c2d139683078 (diff) | |
| download | iced-f37d068af52700570f863960c3432df85a244a7c.tar.gz iced-f37d068af52700570f863960c3432df85a244a7c.tar.bz2 iced-f37d068af52700570f863960c3432df85a244a7c.zip  | |
Rewrite `websocket` example using `sipper`
Diffstat (limited to '')
| -rw-r--r-- | futures/src/backend/native/tokio.rs | 11 | 
1 files changed, 5 insertions, 6 deletions
diff --git a/futures/src/backend/native/tokio.rs b/futures/src/backend/native/tokio.rs index e0be83a6..c38ef566 100644 --- a/futures/src/backend/native/tokio.rs +++ b/futures/src/backend/native/tokio.rs @@ -23,11 +23,10 @@ impl crate::Executor for Executor {  pub mod time {      //! Listen and react to time.      use crate::core::time::{Duration, Instant}; -    use crate::stream;      use crate::subscription::Subscription;      use crate::MaybeSend; -    use futures::SinkExt; +    use futures::stream;      use std::future::Future;      /// Returns a [`Subscription`] that produces messages at a set interval. @@ -66,12 +65,12 @@ pub mod time {              let f = *f;              let interval = *interval; -            stream::channel(1, move |mut output| async move { -                loop { -                    let _ = output.send(f().await).await; - +            stream::unfold(0, move |i| async move { +                if i > 0 {                      tokio::time::sleep(interval).await;                  } + +                Some((f().await, i + 1))              })          })      }  | 
