9个版本
0.3.0 | 2023年8月11日 |
---|---|
0.2.6 | 2023年1月21日 |
0.2.5 | 2022年11月29日 |
0.2.4 | 2022年4月13日 |
0.1.0 | 2019年9月13日 |
#152 in WebAssembly
823,893 每月下载量
在 3,093 个crate中使用 (60直接)
17KB
155 行代码,不包括注释
在Web上处理定时器:setTimeout
和setInterval
。
这些API有两种风格
- 回调风格(更直接地模仿JavaScript API),
- 以及
Future
和Stream
API。
超时
超时在经过一段时间后(以毫秒为单位)触发一次。
带回调函数的超时
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();
作为Future
的超时
启用futures
功能后,将公开一个包含基于future的定时器的future
模块。
依赖项
~1–1.7MB
~30K SLoC