Trait sauron_core::dom::Component
source · pub trait Component<MSG, XMSG> {
// Required methods
fn init(&mut self) -> Vec<Task<MSG>>;
fn update(&mut self, msg: MSG) -> Effects<MSG, XMSG>;
fn view(&self) -> Node<MSG>;
fn stylesheet() -> Vec<String>;
// Provided method
fn style(&self) -> Vec<String> { ... }
}
Expand description
A component has a view and can update itself.
The update function returns an effect which can contain follow ups and effects. Follow ups are executed on the next update loop of this component, while the effects are executed on the parent component that mounts it.
Required Methods§
sourcefn update(&mut self, msg: MSG) -> Effects<MSG, XMSG>
fn update(&mut self, msg: MSG) -> Effects<MSG, XMSG>
Update the model of this component and return follow up and/or effects that will be executed on the next update loop
sourcefn stylesheet() -> Vec<String>
fn stylesheet() -> Vec<String>
component can have static styles
Provided Methods§
Implementors§
impl<CONT, MSG> Component<MSG, ()> for CONTwhere CONT: Container<MSG, ()> + CustomElement<MSG>, MSG: 'static,
Auto implementation of Component trait for Container, which in turn creates an Auto implementation trait for of Application for Container but only if that Container is intended to be a CustomElement