Sunbeam Studios

Our open-source projects, here for you!

gloo-timers (0.3.0)

Published 2026-03-26 10:58:33 +00:00 by siennathesane

Installation

[registry]
default = "gitea"

[registries.gitea]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add gloo-timers@0.3.0

About this package

Convenience crate for working with JavaScript timers

gloo-timers

Crates.io version Download docs.rs docs

API Docs | Contributing | Chat

Built with 🦀🕸 by The 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 gloo_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

ID Version
futures-channel ^0.3
futures-core ^0.3
js-sys ^0.3.31
wasm-bindgen ^0.2
futures-util ^0.3
wasm-bindgen-futures ^0.4.4
wasm-bindgen-test ^0.3.4
Details
Cargo
2026-03-26 10:58:33 +00:00
0
Rust and WebAssembly Working Group
MIT OR Apache-2.0
8.6 KiB
Assets (1)
Versions (1) View all
0.3.0 2026-03-26