pub struct LocalState<ValueType>where
ValueType: 'static,{ /* private fields */ }Expand description
Scoped reactive local component state automatically disposed on unmount and frozen/resumed with its owning Scope.
Implementations§
Source§impl<ValueType> LocalState<ValueType>where
ValueType: 'static,
Scoped local state creation, reading, writing, and change observation for LocalState<T>.
impl<ValueType> LocalState<ValueType>where
ValueType: 'static,
Scoped local state creation, reading, writing, and change observation for LocalState<T>.
Sourcepub fn get_untracked(&self) -> ValueType
pub fn get_untracked(&self) -> ValueType
Sourcepub fn set_if_changed(&self, value: ValueType) -> boolwhere
ValueType: PartialEq,
pub fn set_if_changed(&self, value: ValueType) -> boolwhere
ValueType: PartialEq,
Sourcepub fn try_get_untracked(&self) -> Option<ValueType>where
ValueType: Clone,
pub fn try_get_untracked(&self) -> Option<ValueType>where
ValueType: Clone,
Sourcepub fn watch<CallbackFn>(&self, handler: CallbackFn) -> Effect
pub fn watch<CallbackFn>(&self, handler: CallbackFn) -> Effect
Subscribes a change watcher receiving (&previous, &next) whenever this local state mutates.
§Arguments
&Self- Local state handle.CallbackFn- Change observer invoked on subsequent mutations (skipped duringScope::freeze(), coalesced onScope::resume()).
§Returns
Effect- Scope-owned watcher effect handle.
Trait Implementations§
Source§impl<ValueType> Clone for LocalState<ValueType>where
ValueType: 'static,
Clone handle semantics for LocalState<T>.
impl<ValueType> Clone for LocalState<ValueType>where
ValueType: 'static,
Clone handle semantics for LocalState<T>.
impl<ValueType> Copy for LocalState<ValueType>where
ValueType: 'static,
Copy handle semantics for LocalState<T>.
Source§impl<ValueType> Debug for LocalState<ValueType>where
ValueType: 'static + Debug,
impl<ValueType> Debug for LocalState<ValueType>where
ValueType: 'static + Debug,
impl<ValueType> Eq for LocalState<ValueType>where
ValueType: 'static,
Full equality marker for LocalState<T>.
Auto Trait Implementations§
impl<ValueType> Forget for LocalState<ValueType>
impl<ValueType> Freeze for LocalState<ValueType>
impl<ValueType> Move for LocalState<ValueType>
impl<ValueType> RefUnwindSafe for LocalState<ValueType>
impl<ValueType> Send for LocalState<ValueType>
impl<ValueType> Sync for LocalState<ValueType>
impl<ValueType> Unpin for LocalState<ValueType>
impl<ValueType> UnsafeUnpin for LocalState<ValueType>
impl<ValueType> UnwindSafe for LocalState<ValueType>
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