euv_ui/hook/suspense/struct.rs
1use super::*;
2
3/// A handle that drives a `SuspenseState`.
4///
5/// Created via `SuspenseHandle::new()`. The handle owns
6/// the underlying `Signal<SuspensePhase<T>>` and exposes
7/// `state()` to read it. The handle itself is the only
8/// thing that can mutate the phase, via
9/// `resolve_sync` (every target) or `resolve_async`
10/// (wasm-only).
11#[derive(Clone, Data, Debug)]
12pub struct SuspenseHandle<T: Clone + PartialEq + 'static> {
13 /// The phase signal.
14 ///
15 /// Public because `ui/tests/suspense/fn.rs`,
16 /// `ui/tests/no_dom_fallback/fn.rs` and
17 /// `example/src/page/hooks_async` read it through
18 /// `get_phase()`.
19 pub phase: Signal<SuspensePhase<T>>,
20}
21
22/// `SuspenseHandle<T>` is `Copy` when `T` is — `Signal<...>` is
23/// `Copy` for any `T: Clone + PartialEq + 'static`, so this
24/// blanket impl is sound.
25impl<T> Copy for SuspenseHandle<T> where T: Clone + PartialEq + 'static {}