[][src]Struct yew_state::handle::StateHandle

pub struct StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler, 
{ /* fields omitted */ }

Interface to shared state

Implementations

impl<T, H> StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler<Model = T>, 
[src]

pub fn state(&self) -> &T[src]

pub fn reduce(&self, f: impl FnOnce(&mut T) + 'static)[src]

Apply a function that may mutate shared state. Changes are not immediate, and must be handled in Component::change.

pub fn reduce_callback<E: 'static>(
    &self,
    f: impl Fn(&mut T) + 'static
) -> Callback<E> where
    T: 'static, 
[src]

Convenience method for modifying shared state directly from a Callback. The callback event is ignored here, see reduce_callback_with for the alternative.

pub fn reduce_callback_once<E: 'static>(
    &self,
    f: impl FnOnce(&mut T) + 'static
) -> Callback<E> where
    T: 'static, 
[src]

Convenience method for modifying shared state directly from a CallbackOnce. The callback event is ignored here, see reduce_callback_once_with for the alternative.

pub fn reduce_callback_with<E: 'static>(
    &self,
    f: impl Fn(&mut T, E) + 'static
) -> Callback<E> where
    T: 'static,
    E: Clone
[src]

Convenience method for modifying shared state directly from a Callback. Similar to reduce_callback but it also accepts the fired event.

pub fn reduce_callback_once_with<E: 'static>(
    &self,
    f: impl FnOnce(&mut T, E) + 'static
) -> Callback<E> where
    T: 'static, 
[src]

Convenience method for modifying shared state directly from a CallbackOnce. Similar to reduce_callback but it also accepts the fired event.

Trait Implementations

impl<T, H> Clone for StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler, 
[src]

impl<T: Default, H: Default> Default for StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler, 
[src]

impl<T, H> Handle for StateHandle<T, H> where
    T: Default + Clone,
    H: Handler<Model = T>, 
[src]

type Handler = H

impl<T, H> PartialEq<StateHandle<T, H>> for StateHandle<T, H> where
    T: Default + PartialEq + Clone + 'static,
    H: Handler, 
[src]

impl<T, H> Properties for StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler, 
[src]

type Builder = StateHandleBuilder<T, H, StateHandleBuilderStep_build>

Builder that will be used to construct properties

impl<T, H> SharedState for StateHandle<T, H> where
    T: Default + Clone + 'static,
    H: Handler<Model = T>, 
[src]

type Handle = Self

Auto Trait Implementations

impl<T, H> !RefUnwindSafe for StateHandle<T, H>

impl<T, H> !Send for StateHandle<T, H>

impl<T, H> !Sync for StateHandle<T, H>

impl<T, H> Unpin for StateHandle<T, H> where
    H: Unpin

impl<T, H> !UnwindSafe for StateHandle<T, H>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.