pub struct StateHandle<T: 'static>(/* private fields */);
Expand description
A readonly Signal
.
Returned by functions that provide a handle to access state.
Use Signal::handle
or Signal::into_handle
to retrieve a handle from a Signal
.
Implementations§
Source§impl<T: 'static> StateHandle<T>
impl<T: 'static> StateHandle<T>
Sourcepub fn get_untracked(&self) -> Rc<T>
pub fn get_untracked(&self) -> Rc<T>
Get the current value of the state, without tracking this as a dependency if inside a reactive context.
§Example
use maple_core::prelude::*;
let state = Signal::new(1);
let double = create_memo({
let state = state.clone();
move || *state.get_untracked() * 2
});
assert_eq!(*double.get(), 2);
state.set(2);
// double value should still be old value because state was untracked
assert_eq!(*double.get(), 2);
Trait Implementations§
Source§impl<T: 'static> Clone for StateHandle<T>
impl<T: 'static> Clone for StateHandle<T>
Auto Trait Implementations§
impl<T> Freeze for StateHandle<T>
impl<T> !RefUnwindSafe for StateHandle<T>
impl<T> !Send for StateHandle<T>
impl<T> !Sync for StateHandle<T>
impl<T> Unpin for StateHandle<T>
impl<T> !UnwindSafe for StateHandle<T>
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