pub trait SimpleComponent: Sized + 'static {
    type Input: Debug + 'static;
    type Output: Debug + 'static;
    type Init;
    type Root: Debug + Clone;
    type Widgets: 'static;

    fn init_root() -> Self::Root;
    fn init(
        init: Self::Init,
        root: &Self::Root,
        sender: ComponentSender<Self>
    ) -> ComponentParts<Self>; fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>) { ... } fn update_cmd(
        &mut self,
        input: &Sender<Self::Input>,
        output: Sender<Self::Output>
    ) { ... } fn update_view(
        &self,
        widgets: &mut Self::Widgets,
        sender: ComponentSender<Self>
    ) { ... } fn shutdown(
        &mut self,
        widgets: &mut Self::Widgets,
        output: Sender<Self::Output>
    ) { ... } }
Expand description

Elm-style variant of a Component with view updates separated from input updates.

Required Associated Types§

The message type that the component accepts as inputs.

The message type that the component provides as outputs.

The parameter used to initialize the component.

The widget that was constructed by the component.

The type that’s used for storing widgets created for this component.

Required Methods§

Initializes the root widget

Creates the initial model and view, docking it into the component.

Provided Methods§

Processes inputs received by the component.

Examples found in repository?
src/component/sync/traits.rs (line 201)
200
201
202
    fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>, _root: &Self::Root) {
        C::update(self, message, sender);
    }

Defines how the component should respond to command updates.

Updates the view after the model has been updated.

Examples found in repository?
src/component/sync/traits.rs (line 205)
204
205
206
    fn update_view(&self, widgets: &mut Self::Widgets, sender: ComponentSender<Self>) {
        C::update_view(self, widgets, sender);
    }

Last method called before a component is shut down.

Examples found in repository?
src/component/sync/traits.rs (line 209)
208
209
210
    fn shutdown(&mut self, widgets: &mut Self::Widgets, output: Sender<Self::Output>) {
        self.shutdown(widgets, output);
    }

Implementations on Foreign Types§

An empty, non-interactive component as a placeholder for tests.

Implementors§