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
#![allow(unused_macros)]
pub mod dom_types;
pub mod shortcuts;
pub mod fetch;
pub mod storage;
mod vdom;
mod websys_bridge;
#[macro_use]
extern crate serde_derive;
pub fn run<Ms, Mdl>(model: Mdl, update: fn(Ms, &Mdl) -> Mdl,
view: fn(Mdl) -> dom_types::El<Ms>, mount_point_id: &str)
where Ms: Clone + Sized + 'static, Mdl: Clone + Sized + 'static
{
let app = vdom::App::new(model.clone(), update, view, mount_point_id);
let mut main_el_vdom = (app.data.view)(model);
app.setup_vdom(&mut main_el_vdom, 0, 0);
websys_bridge::attach(&mut main_el_vdom, &app.data.mount_point);
app.data.main_el_vdom.replace(main_el_vdom);
}
pub fn empty<Ms: Clone>() -> dom_types::El<Ms> {
let mut el = dom_types::El::empty(dom_types::Tag::Del);
el.add_attr("dummy-element".into(), "true".into());
el
}
pub fn log(text: &str) {
web_sys::console::log_1(&text.into());
}
pub mod prelude {
pub use crate::dom_types::{El, UpdateEl, UpdateListener,
simple_ev, input_ev, keyboard_ev, raw_ev};
}