Trait sauron::dom::Application

source ·
pub trait Application: Sized + 'static {
    type MSG;

    // Required methods
    fn update(&mut self, _msg: Self::MSG) -> Cmd<Self::MSG>;
    fn view(&self) -> Node<Self::MSG>;

    // Provided methods
    fn init(&mut self) -> Cmd<Self::MSG> { ... }
    fn stylesheet() -> Vec<String> { ... }
    fn style(&self) -> Vec<String> { ... }
    fn measurements(&mut self, _measurements: Measurements) { ... }
}
Expand description

An Application is the root component of your program. Everything that happens in your application is done here.

Required Associated Types§

Required Methods§

source

fn update(&mut self, _msg: Self::MSG) -> Cmd<Self::MSG>

Update the component with a message. The update function returns a Dispatch, which can be executed by the runtime.

Called each time an action is triggered from the view

source

fn view(&self) -> Node<Self::MSG>

Returns a node on how the component is presented.

Provided Methods§

source

fn init(&mut self) -> Cmd<Self::MSG>

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.

source

fn stylesheet() -> Vec<String>

The css style for the application, will be mounted automatically by the program

source

fn style(&self) -> Vec<String>

dynamic style of an application which will be reinjected when the application style changed

source

fn measurements(&mut self, _measurements: Measurements)

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<COMP> Application for COMP
where COMP: Component<XMSG = ()> + StatefulComponent + 'static,

§

type MSG = <COMP as Component>::MSG