1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! # Example
//!
//! ```
//! extern crate kagura;
//! extern crate wasm_bindgen;
//!
//! use kagura::prelude::*;
//! use wasm_bindgen::prelude::*;
//!
//! #[wasm_bindgen(start)]
//! pub fn main() {
//!     kagura::run(Component::new(State, update, render), "app");
//! }
//!
//! struct State;
//!
//! struct Msg;
//!
//! struct Sub;
//!
//! fn update(_: &mut State, _: Msg) -> Cmd<Msg, Sub> {Cmd::none()}
//!
//! fn render(_: &State) -> Html<Msg> {
//!     Html::h1(
//!         Attributes::new(),
//!         Events::new(),
//!         vec![
//!             Html::text("hello kagura"),
//!         ],
//!     )
//! }
//! ```

#[macro_use]
extern crate serde_derive;
extern crate rand;
extern crate wasm_bindgen;

mod bin;
mod component;
mod dom;
mod event;
mod html;
pub mod native;
mod renderer;
mod task;

#[allow(unused_imports)]
use rand::prelude::*;

pub use component::Cmd;
pub use component::Component;
pub use html::Attributes;
pub use html::Events;
pub use html::Html;

/// Starts application with component
pub fn run<Msg, State, Sub>(component: Component<Msg, State, Sub>, id: &str)
where
    Msg: 'static,
    State: 'static,
    Sub: 'static,
{
    bin::run(component, id);
}

pub mod prelude {
    pub use crate::Attributes;
    pub use crate::Cmd;
    pub use crate::Component;
    pub use crate::Events;
    pub use crate::Html;
}