diff options
author | 2025-02-12 01:51:20 +0100 | |
---|---|---|
committer | 2025-02-12 01:51:20 +0100 | |
commit | 89a412695af321356a6f05f9111510d35a839983 (patch) | |
tree | 12b342eb17688cbb07e6c9fd8748c42ef7591501 /futures/src | |
parent | bf205a88b66a6fa8ea6d9a259bfd0ed0b42a97b7 (diff) | |
parent | e78c757cad5619c77a588054b42e9b87335d6e86 (diff) | |
download | iced-89a412695af321356a6f05f9111510d35a839983.tar.gz iced-89a412695af321356a6f05f9111510d35a839983.tar.bz2 iced-89a412695af321356a6f05f9111510d35a839983.zip |
Merge pull request #2805 from iced-rs/feature/sipper-support
`sipper` support and some QoL
Diffstat (limited to 'futures/src')
-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)) }) }) } |