Trait relm4::AsyncComponentUpdate
source · pub trait AsyncComponentUpdate<ParentModel: Model>: Model {
// Required methods
fn init_model(parent_model: &ParentModel) -> Self;
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
msg: Self::Msg,
components: &'life1 Self::Components,
sender: Sender<Self::Msg>,
parent_sender: Sender<ParentModel::Msg>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Available on crate feature
tokio-rt
only.Expand description
ComponentUpdate
for asynchronous workers and components.
Required Methods§
sourcefn init_model(parent_model: &ParentModel) -> Self
fn init_model(parent_model: &ParentModel) -> Self
Initialize the model of the component or worker.
In case you want to share information or settings with the parent component you get the parent’s model passed as parameter.
sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
msg: Self::Msg,
components: &'life1 Self::Components,
sender: Sender<Self::Msg>,
parent_sender: Sender<ParentModel::Msg>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>( &'life0 mut self, msg: Self::Msg, components: &'life1 Self::Components, sender: Sender<Self::Msg>, parent_sender: Sender<ParentModel::Msg> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Update the model. The parent_sender allows to send messages to the parent.