ianaio-timers

Crates.ioianaio-timers
lib.rsianaio-timers
version0.1.1
sourcesrc
created_at2024-02-18 14:24:16.065379
updated_at2024-06-08 07:30:53.77145
descriptionIanaIO crate for working with JavaScript timers
homepagehttps://rustwasm.iana.io/timers/
repositoryhttps://github.com/ianaio/timers
max_upload_size
id1144108
size42,333
ianaio (ianaio)

documentation

https://docs.iana.io/rustwasm/timers

README

ianaio-timers

Crates.io version Download docs.rs docs

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:

  1. a callback style (that more directly mimics the JavaScript APIs), and
  2. a Futures and Streams 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.

Commit count: 14

cargo fmt