Struct relm4::RelmWorker 
source · pub struct RelmWorker<Model, ParentModel>where
    Model: ComponentUpdate<ParentModel, Widgets = ()> + 'static,
    ParentModel: ModelTrait,{ /* private fields */ }Expand description
RelmWorkers are like RelmComponents but they don’t have any widgets.
They are usually used to run expansive tasks on different threads and report back when they are finished
so that their parent components can keep handling UI events in the meantime.
For example you could use a RelmWorker for sending a HTTP request or for copying files.
A RelmWorker has its own model and message type
and can send messages to its parent and its children components.
Multiple RelmWorkers that have the same parent are usually bundled along with RelmComponents
in a struct that implements Components.
Implementations§
source§impl<Model, ParentModel> RelmWorker<Model, ParentModel>where
    Model: ComponentUpdate<ParentModel, Widgets = ()> + 'static,
    ParentModel: ModelTrait,
 
impl<Model, ParentModel> RelmWorker<Model, ParentModel>where Model: ComponentUpdate<ParentModel, Widgets = ()> + 'static, ParentModel: ModelTrait,
sourcepub fn new(
    parent_model: &ParentModel,
    parent_sender: Sender<ParentModel::Msg>
) -> Self
 
pub fn new( parent_model: &ParentModel, parent_sender: Sender<ParentModel::Msg> ) -> Self
Create a new RelmWorker that runs on the main thread.
source§impl<Model, ParentModel> RelmWorker<Model, ParentModel>where
    Model: ComponentUpdate<ParentModel, Widgets = ()> + Send + 'static,
    Model::Components: Send + 'static,
    Model::Msg: Send,
    ParentModel: ModelTrait,
    ParentModel::Msg: Send,
 
impl<Model, ParentModel> RelmWorker<Model, ParentModel>where Model: ComponentUpdate<ParentModel, Widgets = ()> + Send + 'static, Model::Components: Send + 'static, Model::Msg: Send, ParentModel: ModelTrait, ParentModel::Msg: Send,
sourcepub fn with_new_thread(
    parent_model: &ParentModel,
    parent_sender: Sender<ParentModel::Msg>
) -> Self
 
pub fn with_new_thread( parent_model: &ParentModel, parent_sender: Sender<ParentModel::Msg> ) -> Self
Create a new RelmWorker that runs the ComponentUpdate::update function in another thread.
Trait Implementations§
source§impl<Model, ParentModel> Clone for RelmWorker<Model, ParentModel>where
    Model: ComponentUpdate<ParentModel, Widgets = ()> + 'static + Clone,
    ParentModel: ModelTrait + Clone,
    Model::Msg: Clone,
 
impl<Model, ParentModel> Clone for RelmWorker<Model, ParentModel>where Model: ComponentUpdate<ParentModel, Widgets = ()> + 'static + Clone, ParentModel: ModelTrait + Clone, Model::Msg: Clone,
source§fn clone(&self) -> RelmWorker<Model, ParentModel>
 
fn clone(&self) -> RelmWorker<Model, ParentModel>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read more