Trait relm4::prelude::SimpleComponent
source · pub trait SimpleComponent: Sized + 'static {
type Input: Debug + 'static;
type Output: Debug + 'static;
type Init;
type Root: Debug + Clone;
type Widgets: 'static;
// Required methods
fn init_root() -> Self::Root;
fn init(
init: Self::Init,
root: &Self::Root,
sender: ComponentSender<Self>
) -> ComponentParts<Self>;
// Provided methods
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§
Required Methods§
sourcefn init(
init: Self::Init,
root: &Self::Root,
sender: ComponentSender<Self>
) -> ComponentParts<Self>
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§
sourcefn update(&mut self, message: Self::Input, sender: ComponentSender<Self>)
fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>)
Processes inputs received by the component.
sourcefn update_cmd(
&mut self,
input: &Sender<Self::Input>,
output: Sender<Self::Output>
)
fn update_cmd( &mut self, input: &Sender<Self::Input>, output: Sender<Self::Output> )
Defines how the component should respond to command updates.
sourcefn update_view(
&self,
widgets: &mut Self::Widgets,
sender: ComponentSender<Self>
)
fn update_view( &self, widgets: &mut Self::Widgets, sender: ComponentSender<Self> )
Updates the view after the model has been updated.
Implementations on Foreign Types§
source§impl SimpleComponent for ()
impl SimpleComponent for ()
An empty, non-interactive component as a placeholder for tests.