Trait yew_agent::utils::store::Store [−][src]
pub trait Store: Sized + 'static {
type Input;
type Action;
fn new() -> Self;
fn handle_input(
&self,
link: AgentLink<StoreWrapper<Self>>,
msg: Self::Input
);
fn reduce(&mut self, msg: Self::Action);
}Expand description
A functional state wrapper, enforcing a unidirectional data flow and consistent state to the observers.
handle_input receives incoming messages from components,
reduce applies changes to the state
The state is sent once whenever a bridge is opened and then once
for each Action sent by the handle_input function. This means
the initial state of the store must be valid for the consumers.
Once created with a first bridge, a Store will never be destroyed for the lifetime of the application.
Associated Types
Required methods
fn handle_input(&self, link: AgentLink<StoreWrapper<Self>>, msg: Self::Input)
fn handle_input(&self, link: AgentLink<StoreWrapper<Self>>, msg: Self::Input)
Receives messages from components and other agents. Use the link
to send actions to itself in order to notify reduce once your
operation completes. This is the place to do side effects, like
talking to the server, or asking the user for input.
Note that you can look at the state of your Store, but you cannot modify it here. If you want to modify it, send a Message to the reducer
