2020-04-30 05:37:44 +02:00
|
|
|
//! Listen and react to time.
|
2025-01-24 18:47:34 +01:00
|
|
|
pub use crate::core::time::*;
|
2022-01-28 18:43:20 +07:00
|
|
|
|
2023-03-27 15:43:52 +02:00
|
|
|
#[allow(unused_imports)]
|
2024-01-08 16:00:17 +01:00
|
|
|
#[cfg_attr(
|
|
|
|
|
docsrs,
|
|
|
|
|
doc(cfg(any(
|
|
|
|
|
feature = "tokio",
|
|
|
|
|
feature = "smol",
|
|
|
|
|
target_arch = "wasm32"
|
|
|
|
|
)))
|
|
|
|
|
)]
|
2022-01-28 18:24:07 +07:00
|
|
|
pub use iced_futures::backend::default::time::*;
|
2025-09-06 17:07:24 +02:00
|
|
|
|
|
|
|
|
use crate::Task;
|
|
|
|
|
|
|
|
|
|
/// Returns a [`Task`] that produces the current [`Instant`]
|
|
|
|
|
/// by calling [`Instant::now`].
|
|
|
|
|
///
|
2025-09-06 17:15:27 +02:00
|
|
|
/// While you can call [`Instant::now`] directly in your application;
|
|
|
|
|
/// that renders your application "impure" (i.e. no referential transparency).
|
2025-09-06 17:07:24 +02:00
|
|
|
///
|
|
|
|
|
/// You may care about purity if you want to leverage the `time-travel`
|
|
|
|
|
/// feature properly.
|
|
|
|
|
pub fn now() -> Task<Instant> {
|
|
|
|
|
Task::future(async { Instant::now() })
|
|
|
|
|
}
|