[][src]Crate kagura

Example

extern crate kagura;
extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

use hello_component::HelloComponent;

#[wasm_bindgen(start)]
pub fn main() {
    kagura::run::<HelloComponent, _, _, _>("app", hello_component::Props {}, vec![]);
}

mod hello_component {
    use kagura::prelude::*;

    pub struct Props {}
    pub enum Msg {}
    pub enum Sub {}

    pub struct HelloComponent {}

    impl Constructor for HelloComponent {
        fn constructor(_: Self::Props, _: &mut ComponentBuilder<Msg, Sub>) -> Self {
            Self {}
        }
    }

    impl Component for HelloComponent {
        type Props = Props;
        type Msg = Msg;
        type Sub = Sub;

        fn init(&mut self, _: Self::Props, _: &mut ComponentBuilder<Msg, Sub>) {}

        fn update(&mut self, _: Self::Msg) -> Cmd<Msg, Sub> {
            Cmd::none()
        }

        fn render(&self, _: Vec<Html>) -> Html {
            Html::h1(
                Attributes::new(),
                Events::new(),
                vec![Html::text("Hello Kagura")],
            )
        }
    }
}

Modules

component
prelude

Functions

run

Starts application with component