pub trait App: Default {
type Event: Send + 'static;
type Model: Default;
type ViewModel: Serialize;
type Capabilities;
// Required methods
fn update(
&self,
event: Self::Event,
model: &mut Self::Model,
caps: &Self::Capabilities,
);
fn view(&self, model: &Self::Model) -> Self::ViewModel;
}
Expand description
Required Associated Types§
sourcetype Event: Send + 'static
type Event: Send + 'static
Event, typically an enum
, defines the actions that can be taken to update the application state.
sourcetype ViewModel: Serialize
type ViewModel: Serialize
ViewModel, typically a struct
describes the user interface that should be
displayed to the user
sourcetype Capabilities
type Capabilities
Capabilities, typically a struct
, lists the capabilities used by this application
Typically, Capabilities should contain at least an instance of the built-in Render
capability.
Required Methods§
sourcefn update(
&self,
event: Self::Event,
model: &mut Self::Model,
caps: &Self::Capabilities,
)
fn update( &self, event: Self::Event, model: &mut Self::Model, caps: &Self::Capabilities, )
Update method defines the transition from one model
state to another in response to an event
.
Update function can mutate the model
and use the capabilities provided by the caps
argument
to instruct the shell to perform side-effects. The side-effects will run concurrently (capability
calls behave the same as go routines in Go or Promises in JavaScript). Capability calls
don’t return anything, but may take a callback
event which should be dispatched when the
effect completes.
Typically, update
should call at least Render::render
.