Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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

Source§

type MSG = <COMP as Component>::MSG