blob: ed917632f73321f89bd2242b7fda4ed9dac4ee2a (
plain)
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
|
import lustre
import lustre/element.{type Element, element}
import lustre/element/html
import lustre/event
// MAIN ------------------------------------------------------------------------
pub fn main() {
let app = lustre.simple(init, update, view)
let assert Ok(_) = lustre.start(app, "#app", Nil)
}
// MODEL -----------------------------------------------------------------------
type Model =
String
fn init(_flags) -> Model {
"div"
}
// UPDATE ----------------------------------------------------------------------
pub opaque type Baby {
Waaa
}
pub opaque type Child {
BabyMsg(Baby)
}
pub opaque type Msg {
ChildMsg(Child)
}
fn update(model: Model, _msg: Msg) -> Model {
model
}
// VIEW ------------------------------------------------------------------------
fn view(_model: Model) -> Element(Msg) {
html.div([], [
html.text("parent"),
html.div([], [
html.text("child"),
html.div([event.on_click(Waaa)], [html.text("baby")])
|> element.map(BabyMsg),
])
|> element.map(ChildMsg),
])
}
|