iced/time.rs
1//! Listen and react to time.
2pub use crate::core::time::*;
3
4#[allow(unused_imports)]
5#[cfg_attr(
6 docsrs,
7 doc(cfg(any(
8 feature = "tokio",
9 feature = "smol",
10 target_arch = "wasm32"
11 )))
12)]
13pub use iced_futures::backend::default::time::*;
14
15use crate::Task;
16
17/// Returns a [`Task`] that produces the current [`Instant`]
18/// by calling [`Instant::now`].
19///
20/// While you can call [`Instant::now`] directly in your application;
21/// that renders your application "impure" (i.e. no referential transparency).
22///
23/// You may care about purity if you want to leverage the `time-travel`
24/// feature properly.
25pub fn now() -> Task<Instant> {
26 Task::future(async { Instant::now() })
27}