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(feature = "tokio", feature = "smol", target_arch = "wasm32")))
8)]
9pub use iced_futures::backend::default::time::*;
10
11use crate::Task;
12
13/// Returns a [`Task`] that produces the current [`Instant`]
14/// by calling [`Instant::now`].
15///
16/// While you can call [`Instant::now`] directly in your application;
17/// that renders your application "impure" (i.e. no referential transparency).
18///
19/// You may care about purity if you want to leverage the `time-travel`
20/// feature properly.
21pub fn now() -> Task<Instant> {
22 Task::future(async { Instant::now() })
23}