[][src]Trait savory_core::element::AppElementExt

pub trait AppElementExt where
    Self: Element<Config = Url> + View<Node<Self::Message>> + Sized
{ fn start() -> App<Self::Message, Self, Node<Self::Message>> { ... }
fn start_at(id: &str) -> App<Self::Message, Self, Node<Self::Message>> { ... } }

Extension trait for Element when it's used on App element

This trait provides functions that mounts the app element on HTML node by integrating app element with seed::app::App

Provided methods

fn start() -> App<Self::Message, Self, Node<Self::Message>>

Start app element

Example

use savory_core::prelude::*;
use wasm_bindgen::prelude::*;

pub struct MyApp;

pub enum Msg {
    FooMessage,
}

impl Element for MyApp {
    type Message = Msg;
    type Config = Url;

    fn init(url: Url, orders: &mut impl Orders<Msg>) -> Self {
        // initialize the app goes here
        todo!()
    }

    fn update(&mut self, msg: Msg, orders: &mut impl Orders<Msg>) {
        // handling app messages goes here
        todo!()
    }
}

impl View<Node<Msg>> for MyApp {
    fn view(&self) -> Node<Msg> {
        // viewing the app goes here
        todo!()
    }
}

#[wasm_bindgen(start)]
pub fn view() {
    MyApp::start();
}

fn start_at(id: &str) -> App<Self::Message, Self, Node<Self::Message>>

Start app element at specifec element that matchs the id passed

Loading content...

Implementors

impl<T> AppElementExt for T where
    Self: Element<Config = Url> + View<Node<Self::Message>> + Sized
[src]

Loading content...