Trait sauron_core::dom::Component
source · [−]pub trait Component<MSG, XMSG> {
fn update(&mut self, msg: MSG) -> Effects<MSG, XMSG>;
fn view(&self) -> Node<MSG>;
fn style(&self) -> String { ... }
fn get_component_id(&self) -> Option<&String> { ... }
fn observed_attributes() -> Vec<&'static str> { ... }
fn attributes_changed(
&mut self,
_attributes_values: BTreeMap<String, String>
) { ... }
fn attributes_for_mount(&self) -> BTreeMap<String, 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
Update the model of this component and return follow up and/or effects that will be executed on the next update loop
Provided Methods
fn get_component_id(&self) -> Option<&String>
fn get_component_id(&self) -> Option<&String>
Component can have component id to identify themselves
fn observed_attributes() -> Vec<&'static str>
fn observed_attributes() -> Vec<&'static str>
returns the attributes that is observed by this component
fn attributes_changed(&mut self, _attributes_values: BTreeMap<String, String>)
fn attributes_changed(&mut self, _attributes_values: BTreeMap<String, String>)
This will be invoked when a component is used as a custom element and the attributes of the custom-element has been modified
fn attributes_for_mount(&self) -> BTreeMap<String, String>
fn attributes_for_mount(&self) -> BTreeMap<String, String>
This will be invoked when a component needs to set the attributes for the mounted element of this component