pub trait Model: Sized {
type Msg: 'static;
type Widgets;
type Components: Components<Self>;
}
Expand description
Trait that defines the types associated with the model.
A model can be anything that stores application state.
Example
struct AppModel {
counter: u8,
}
enum AppMsg {
Increment,
Decrement,
}
impl Model for AppModel {
type Msg = AppMsg;
type Widgets = AppWidgets;
type Components = ();
}
Required Associated Types§
sourcetype Msg: 'static
type Msg: 'static
The message type that defines the messages that can be sent to modify the model.
sourcetype Widgets
type Widgets
The widgets type that can initialize and update the GUI with the data the model provides.
If you don’t want any widgets (for example for defining a worker), just use ()
here.
sourcetype Components: Components<Self>
type Components: Components<Self>
The components type that initializes the child components of this model.
If you don’t want any component associated with this model just use ()
.