Trait relm4::AppUpdate

source ·
pub trait AppUpdate: Model {
    // Required method
    fn update(
        &mut self,
        msg: Self::Msg,
        components: &Self::Components,
        sender: Sender<Self::Msg>
    ) -> bool;
}
Expand description

Define the behavior to update the model of the main app.

Example

impl AppUpdate for AppModel {
    fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
        match msg {
            AppMsg::Increment => {
                self.counter += 1;
            }
            AppMsg::Decrement => {
                self.counter -= 1;
            }
        }
        true
    }
}

Required Methods§

source

fn update( &mut self, msg: Self::Msg, components: &Self::Components, sender: Sender<Self::Msg> ) -> bool

Updates the model. Typically a match statement is used to process the message.

Return true to continue running the application and return false to quit.

Components and sender don’t need to be used but help you sending messages to your components or queuing messages for self.

Implementors§