logo
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

The message type that defines the messages that can be sent to modify the model.

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.

The components type that initializes the child components of this model.

If you don’t want any component associated with this model just use ().

Implementations on Foreign Types

Implementors