Trait sauron_core::dom::Application
source · pub trait Application<MSG>where
MSG: 'static,{
// Required methods
fn init(&mut self) -> Vec<Cmd<Self, MSG>>
where Self: Sized + 'static;
fn update(&mut self, _msg: MSG) -> Cmd<Self, MSG>
where Self: Sized + 'static;
fn view(&self) -> Node<MSG>;
fn stylesheet() -> Vec<String>;
// Provided methods
fn style(&self) -> Vec<String> { ... }
fn measurements(&self, measurements: Measurements) -> Cmd<Self, MSG>
where Self: Sized + 'static { ... }
}
Expand description
An Application is the root component of your program. Everything that happens in your application is done here.
Required Methods§
sourcefn init(&mut self) -> Vec<Cmd<Self, MSG>>where
Self: Sized + 'static,
fn init(&mut self) -> Vec<Cmd<Self, MSG>>where Self: Sized + 'static,
The application can implement this method where it can modify its initial state. This method is called right after the program is mounted into the DOM.
sourcefn update(&mut self, _msg: MSG) -> Cmd<Self, MSG>where
Self: Sized + 'static,
fn update(&mut self, _msg: MSG) -> Cmd<Self, MSG>where Self: Sized + 'static,
Update the component with a message. The update function returns a Cmd, which can be executed by the runtime.
Called each time an action is triggered from the view
sourcefn stylesheet() -> Vec<String>
fn stylesheet() -> Vec<String>
The css style for the application, will be mounted automatically by the program
Provided Methods§
sourcefn style(&self) -> Vec<String>
fn style(&self) -> Vec<String>
dynamic style of an application which will be reinjected when the application style changed
sourcefn measurements(&self, measurements: Measurements) -> Cmd<Self, MSG>where
Self: Sized + 'static,
fn measurements(&self, measurements: Measurements) -> Cmd<Self, MSG>where Self: Sized + 'static,
This is called after dispatching and updating the dom for the component This is for diagnostic and performance measurement purposes.
Warning: DO NOT use for anything else other than the intended purpose
Implementors§
impl<COMP, MSG> Application<MSG> for COMPwhere COMP: Component<MSG, ()> + 'static + CustomElement<MSG>, MSG: 'static,
Auto implementation of Application trait for Component that has no external MSG but only if that Component is intended to be a CustomElement