Struct sycamore::prelude::StateHandle [−][src]
pub struct StateHandle<T>(_)
where
T: 'static;
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
Get the current value of the state. When called inside a reactive scope, calling this will add itself to the scope’s dependencies.
Example
use sycamore_reactive::*;
let state = Signal::new(0);
assert_eq!(*state.get(), 0);
state.set(1);
assert_eq!(*state.get(), 1);
Get the current value of the state, without tracking this as a dependency if inside a reactive context.
Example
use sycamore_reactive::*;
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
Returns the “default value” for a type. Read more
pub fn deserialize<D>(
deserializer: D
) -> Result<StateHandle<T>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<StateHandle<T>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
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
Mutably borrows from an owned value. Read more