Trait relm4::Components

source ·
pub trait Components<ParentModel: ?Sized + Model> {
    fn init_components(
        parent_model: &ParentModel,
        parent_sender: Sender<ParentModel::Msg>
    ) -> Self; fn connect_parent(&mut self, _parent_widgets: &ParentModel::Widgets); }
Expand description

Define how to initialize one or more components.

Typically a struct is used to store multiple components that are child components of the app or another component.


struct AppComponents {
    comp1: RelmComponent<Comp1Model, AppModel>,
    comp2: RelmComponent<Comp2Model, AppModel>,

impl Components<AppModel> for AppComponents {
    fn init_components(parent_model: &AppModel, parent_sender: Sender<AppMsg>) -> Self {
        AppComponents {
            comp1: RelmComponent::new(parent_model, parent_sender.clone()),
            comp2: RelmComponent::new(parent_model, parent_sender),

    fn connect_parent(&mut self, parent_widgets: &AppWidgets) {

Required Methods§

Initialize your components and workers inside this function.

Connect the components to their parent components widgets (to set the parent window for example).

Implementations on Foreign Types§