Trait relm4::AsyncComponentUpdate
source · [−]pub trait AsyncComponentUpdate<ParentModel: Model>: Model {
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
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
}
This is supported on crate feature
tokio-rt
only.Expand description
ComponentUpdate
for asynchronous workers and components.
Required methods
fn 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.
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
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Update the model. The parent_sender allows to send messages to the parent.