[][src]Macro yarte_wasm_app::run

macro_rules! run {
    ($ty:ty) => { ... };
}

Macro to create a A<App: App> reference to a statically allocated App.

This macro returns a value with type &'static Addr<$ty>.

Panics

Have one type instance Only construct to target arch wasm32

This example is not tested
#[derive(App)]
#[template(path = "index")
#[msg(enum Msg { Inc, Reset })]
struct MyApp {
    count: usize,
    bb: <Self as App>::BlackBox,
}

fn inc(app: &mut MyApp, _addr: &Addr<MyApp>) {
    set_count!(app, app.count + 1);
}

fn reset(app: &mut MyApp, _addr: &Addr<MyApp>) {
    if app.count != 0 {
        set_count!(app, 0);
    }
}

let addr = run!(MyApp);
addr.send(Msg::Reset);