Fix `time::Every` implementation for `smol` runtime
This commit is contained in:
parent
bcc54b0831
commit
fd2c96c8e3
|
@ -6,4 +6,4 @@ edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced = { path = "../..", features = ["tokio"] }
|
iced = { path = "../..", features = ["smol"] }
|
||||||
|
|
|
@ -37,7 +37,7 @@ optional = true
|
||||||
features = ["unstable"]
|
features = ["unstable"]
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.smol]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.smol]
|
||||||
version = "1.0"
|
version = "1.2"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
|
|
@ -35,8 +35,16 @@ where
|
||||||
_input: futures::stream::BoxStream<'static, E>,
|
_input: futures::stream::BoxStream<'static, E>,
|
||||||
) -> futures::stream::BoxStream<'static, Self::Output> {
|
) -> futures::stream::BoxStream<'static, Self::Output> {
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
smol::Timer::interval(self.0).boxed()
|
let duration = self.0;
|
||||||
|
|
||||||
|
futures::stream::unfold(Instant::now(), move |last_tick| async move {
|
||||||
|
let last_tick = smol::Timer::at(last_tick + duration).await;
|
||||||
|
|
||||||
|
Some((last_tick, last_tick))
|
||||||
|
})
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue