[][src]Trait yew_state::Handle

pub trait Handle {
    type Handler: Handler;
    fn state(&self) -> &<Self::Handler as Handler>::Model;
fn callback(
        &self
    ) -> &Callback<Box<dyn FnOnce(&mut <Self::Handler as Handler>::Model)>>; fn reduce(
        &self,
        f: impl FnOnce(&mut <Self::Handler as Handler>::Model) + 'static
    ) { ... }
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
, { ... }
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
, { ... } }

Primary shared state interface

Associated Types

type Handler: Handler

Loading content...

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)>>

Callback to use for updating state.

Loading content...

Provided methods

fn reduce(
    &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, 

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, 

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

Loading content...

Implementors

Loading content...