1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use *;
/// A value that only emits after a quiet period of
/// `delay` since its most recent `set`.
///
/// Constructed via `DebouncedValue::new(delay_ms)`
/// (Lombok `New`); the emitted value starts at
/// `T::default()` and the throttle state starts at
/// `Idle`. Use [`DebouncedValue::set`] (or
/// [`DebouncedValue::tick`] with a backdated timestamp)
/// to seed the emitted value.
///
/// Typical use: pair with `App::use_interval` — the
/// interval callback calls `tick(now_ms)` every
/// N milliseconds, where `now_ms` comes from
/// `performance.now()` on the web. After `delay_ms`
/// without a fresh `set`, the pending value is committed.
///
/// This shape keeps the hook free of any browser /
/// timer dependency so the same code runs in
/// `cargo test` and in `wasm32-unknown-unknown` — the
/// caller supplies the time source as plain milliseconds
/// (`std::time::Instant::now()` panics on wasm, so the
/// hook API deliberately takes `u64` millis).
/// `DebouncedValue<T>` is `Copy` when `T` is — every field
/// (`Signal<T>`, `Signal<DebounceState<T>>`, `u32`) is itself
/// `Copy`, so the blanket impl is sound.