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§

source

type Input: Debug + 'static

The message type that the component accepts as inputs.

source

type Output: Debug + 'static

The message type that the component provides as outputs.

source

type Init

The parameter used to initialize the component.

source

type Root: Debug + Clone

The widget that was constructed by the component.

source

type Widgets: 'static

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

Required Methods§

source

fn init_root() -> Self::Root

Initializes the root widget

source

fn init(
init: Self::Init,
root: &Self::Root,
sender: ComponentSender<Self>
) -> ComponentParts<Self>

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

Provided Methods§

source

fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>)

Processes inputs received by the component.

source

fn update_cmd(
&mut self,
input: &Sender<Self::Input>,
output: Sender<Self::Output>
)

Defines how the component should respond to command updates.

source

fn update_view(&self, widgets: &mut Self::Widgets, sender: ComponentSender<Self>)

Updates the view after the model has been updated.

source

fn shutdown(&mut self, widgets: &mut Self::Widgets, output: Sender<Self::Output>)

Last method called before a component is shut down.

Implementations on Foreign Types§

source§

impl SimpleComponent for ()

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

§

type Input = ()

§

type Output = ()

§

type Init = ()

§

type Root = ()

§

type Widgets = ()

source§

fn init_root() -> Self::Root

source§

fn init(
_init: Self::Init,
_root: &Self::Root,
_sender: ComponentSender<Self>
) -> ComponentParts<Self>

Implementors§

source§

impl<T> SimpleComponent for Twhere
T: Worker + 'static,

§

type Root = ()

§

type Widgets = ()

§

type Init = <T as Worker>::Init

§

type Input = <T as Worker>::Input

§

type Output = <T as Worker>::Output