pub struct GlobalState;Expand description
App-wide reactive global state registry supporting type-keyed and named singleton stores plus scope-aware watch observers.
Implementations§
Source§impl GlobalState
Global singleton state registration, access, mutation, and scope-aware change watching for GlobalState.
impl GlobalState
Global singleton state registration, access, mutation, and scope-aware change watching for GlobalState.
Sourcepub fn use_state<ValueType>() -> Option<Signal<ValueType>>where
ValueType: 'static,
pub fn use_state<ValueType>() -> Option<Signal<ValueType>>where
ValueType: 'static,
Looks up a previously registered global state signal of type T.
§Returns
Option<Signal<ValueType>>- Registered global signal if present.
Sourcepub fn use_or_init<ValueType, CallbackFn>(init: CallbackFn) -> Signal<ValueType>where
ValueType: 'static,
CallbackFn: FnOnce() -> ValueType,
pub fn use_or_init<ValueType, CallbackFn>(init: CallbackFn) -> Signal<ValueType>where
ValueType: 'static,
CallbackFn: FnOnce() -> ValueType,
Sourcepub fn get<ValueType>() -> Option<ValueType>where
ValueType: Clone + 'static,
pub fn get<ValueType>() -> Option<ValueType>where
ValueType: Clone + 'static,
Reactively reads the current value of global state T, tracking dependency on the active observer.
§Returns
Option<ValueType>- Current global state value if registered.
Sourcepub fn get_untracked<ValueType>() -> Option<ValueType>where
ValueType: Clone + 'static,
pub fn get_untracked<ValueType>() -> Option<ValueType>where
ValueType: Clone + 'static,
Reads the current value of global state T without tracking reactive dependencies.
§Returns
Option<ValueType>- Current global state value if registered.
Sourcepub fn set_if_changed<ValueType>(value: ValueType) -> boolwhere
ValueType: PartialEq + 'static,
pub fn set_if_changed<ValueType>(value: ValueType) -> boolwhere
ValueType: PartialEq + 'static,
Sourcepub fn watch<ValueType, CallbackFn>(handler: CallbackFn) -> Option<Effect>
pub fn watch<ValueType, CallbackFn>(handler: CallbackFn) -> Option<Effect>
Subscribes a scope-owned change watcher receiving (&previous, &next) whenever global state T updates.
§Arguments
CallbackFn- Change callback (automatically suspended when owning page is frozen and coalesced on resume).
§Returns
Option<Effect>- Watcher effect handle if global stateTis registered.
Sourcepub fn provide_named<ValueType>(
name: &str,
initial: ValueType,
) -> Signal<ValueType>where
ValueType: 'static,
pub fn provide_named<ValueType>(
name: &str,
initial: ValueType,
) -> Signal<ValueType>where
ValueType: 'static,
Sourcepub fn watch_named<ValueType, CallbackFn>(
name: &str,
handler: CallbackFn,
) -> Option<Effect>
pub fn watch_named<ValueType, CallbackFn>( name: &str, handler: CallbackFn, ) -> Option<Effect>
Trait Implementations§
Source§impl Clone for GlobalState
impl Clone for GlobalState
impl Copy for GlobalState
Source§impl Debug for GlobalState
impl Debug for GlobalState
Source§impl Default for GlobalState
impl Default for GlobalState
impl Eq for GlobalState
Source§impl PartialEq for GlobalState
impl PartialEq for GlobalState
impl StructuralPartialEq for GlobalState
Auto Trait Implementations§
impl Forget for GlobalState
impl Freeze for GlobalState
impl Move for GlobalState
impl RefUnwindSafe for GlobalState
impl Send for GlobalState
impl Sync for GlobalState
impl Unpin for GlobalState
impl UnsafeUnpin for GlobalState
impl UnwindSafe for GlobalState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more