Implement time::every in iced_futures

This commit is contained in:
Héctor Ramón Jiménez 2020-04-30 05:37:44 +02:00
parent bb9ccc4f62
commit e2076612cb
14 changed files with 110 additions and 169 deletions

View file

@ -190,6 +190,10 @@ pub mod settings;
pub mod widget;
pub mod window;
#[cfg(any(feature = "tokio", feature = "async-std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tokio", feature = "async-std"))))]
pub mod time;
#[doc(no_inline)]
pub use widget::*;

14
src/time.rs Normal file
View file

@ -0,0 +1,14 @@
//! Listen and react to time.
use crate::Subscription;
/// Returns a [`Subscription`] that produces messages at a set interval.
///
/// The first message is produced after a `duration`, and then continues to
/// produce more messages every `duration` after that.
///
/// [`Subscription`]: ../subscription/struct.Subscription.html
pub fn every(
duration: std::time::Duration,
) -> Subscription<std::time::Instant> {
iced_futures::time::every(duration)
}