Trait relm4::MicroWidgets

source ·
pub trait MicroWidgets<Model: MicroModel + ?Sized> {
    type Root: Debug;

    // Required methods
    fn init_view(model: &Model, sender: Sender<Model::Msg>) -> Self;
    fn view(&mut self, model: &Model, sender: Sender<Model::Msg>);
    fn root_widget(&self) -> Self::Root;
Expand description

Define behavior to turn the data of your MicroModel into widgets.

Required Associated Types§


type Root: Debug

The root represents the first widget that all other widgets of this MicroComponent are attached to.

Required Methods§


fn init_view(model: &Model, sender: Sender<Model::Msg>) -> Self

Initialize the UI.

Use the sender to connect UI events and send messages back to modify the model.


fn view(&mut self, model: &Model, sender: Sender<Model::Msg>)

Update the view to represent the updated model.


fn root_widget(&self) -> Self::Root

Return a clone of the root widget. This is typically a GTK4 widget.