pub trait Application<MSG>where
    MSG: 'static,{
    // Required methods
    fn update(&mut self, _msg: MSG) -> Cmd<Self, MSG>
       where Self: Sized + 'static;
    fn view(&self) -> Node<MSG>;
    fn style(&self) -> String;

    // Provided methods
    fn init(&mut self) -> Cmd<Self, MSG>
       where Self: Sized + 'static { ... }
    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§

source

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

source

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

Returns a node on how the component is presented.

source

fn style(&self) -> String

optionally an Application can specify its own css style

Provided Methods§

source

fn init(&mut self) -> 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.

source

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§

source§

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