[−][src]Trait yew_state::Handle
Primary shared state interface
Associated Types
type Handler: Handler
Required methods
fn state(&self) -> &<Self::Handler as Handler>::Model
Current state.
fn callback(
&self
) -> &Callback<Box<dyn FnOnce(&mut <Self::Handler as Handler>::Model)>>
&self
) -> &Callback<Box<dyn FnOnce(&mut <Self::Handler as Handler>::Model)>>
Callback to use for updating state.
Provided methods
fn reduce(
&self,
f: impl FnOnce(&mut <Self::Handler as Handler>::Model) + 'static
)
&self,
f: impl FnOnce(&mut <Self::Handler as Handler>::Model) + 'static
)
Apply a function that may mutate shared state.
Changes are not immediate, and must be handled in Component::change.
fn reduce_callback<T: 'static>(
&self,
f: impl FnOnce(&mut <Self::Handler as Handler>::Model) + Copy + 'static
) -> Callback<T> where
<Self::Handler as Handler>::Model: 'static,
&self,
f: impl FnOnce(&mut <Self::Handler as Handler>::Model) + Copy + 'static
) -> Callback<T> where
<Self::Handler as Handler>::Model: 'static,
Convenience method for modifying shared state directly from a callback.
The callback event is ignored here, see reduce_callback_with for the alternative.
fn reduce_callback_with<T: 'static>(
&self,
f: impl FnOnce(T, &mut <Self::Handler as Handler>::Model) + Copy + 'static
) -> Callback<T> where
<Self::Handler as Handler>::Model: 'static,
&self,
f: impl FnOnce(T, &mut <Self::Handler as Handler>::Model) + Copy + 'static
) -> Callback<T> where
<Self::Handler as Handler>::Model: 'static,
Convenience method for modifying shared state directly from a callback.
Similar to reduce_callback but it also accepts the fired event.