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
46
47
48
use *;
/// A value that emits the most recent input at most once
/// per `interval_ms`.
///
/// Constructed via `ThrottledValue::new(interval_ms)`
/// (Lombok `New`); the emitted value starts at
/// `T::default()` and the throttle state starts at
/// `Idle`. Use [`ThrottledValue::set`] to seed the
/// emitted value.
///
/// Unlike [`DebouncedValue`], which waits for a quiet
/// period, a throttled value commits a snapshot every
/// `interval_ms` regardless of how often `set` was called.
///
/// Pair with `App::use_interval` — the interval callback
/// calls `tick(now_ms)` every `interval_ms`, where
/// `now_ms` comes from `performance.now()` on the web.
/// The caller picks the time source (plain `u64` millis)
/// so the hook stays free of browser / timer dependencies
/// and works on `wasm32-unknown-unknown` (where
/// `std::time::Instant::now()` panics).
/// `ThrottledValue<T>` is `Copy` when `T` is — every field
/// is itself `Copy` (`Signal<T>`, `Signal<Option<T>>`, `u32`)
/// or a simple `enum`, so the blanket impl is sound.