2 releases
| 0.1.1 | Jun 8, 2024 |
|---|---|
| 0.1.0 | Feb 18, 2024 |
#932 in WebAssembly
74 downloads per month
Used in 5 crates
(3 directly)
17KB
155 lines
ianaio-timers
API Docs | Contributing | Chat
Built with 🦀🕸 by The IanaIO Rust and WebAssembly Working Group
Working with timers on the Web: setTimeout and setInterval.
These APIs come in two flavors:
- a callback style (that more directly mimics the JavaScript APIs), and
- a
Futures andStreams API.
Timeouts
Timeouts fire once after a period of time (measured in milliseconds).
Timeouts with a Callback Function
use ianaio_timers::callback::Timeout;
let timeout = Timeout::new(1_000, move || {
// Do something after the one second timeout is up!
});
// Since we don't plan on cancelling the timeout, call `forget`.
timeout.forget();
Timeouts as Futures
With the futures feature enabled, a future module containing futures-based
timers is exposed.
Dependencies
~0.8–1.6MB
~28K SLoC