-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.fs
70 lines (58 loc) · 1.86 KB
/
Program.fs
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
// module HelloApp
// open Browser
// open Browser.Types
// open Fable.Core.JsInterop
// open Van.Basic // import tags, add
// let a: Tag = tags?a
// let p: Tag = tags?p
// let div: Tag = tags?div
// let ul: Tag = tags?ul
// let li: Tag = tags?li
// let Hello =
// fun _ ->
// div [
// p ["👋Hello"]
// ul [
// li ["🗺️World"]
// li [a [{|href="https://vanjs.org/"|}; "🍦VanJS"]]
// ]
// ]
// add [document.body; Hello()]
// |> ignore
module CounterApp
open Browser
open Browser.Types
open Fable.Core.JsInterop
open Van.Basic // import tags, add
open Van.TimelineElement // import Timeline
let div: Tag = tags?div
let h2: Tag = tags?h2
let icon: Tag = tags?``md-icon``
let iconButton: Tag = tags?``md-icon-button``
let Counter =
fun _ ->
let counter = TimelineE 0 // ① initialize an Timeline
counter // ② the binary operation of the Timeline
|> TLE.map (fun value ->
console.log $"Counter: {value}")
|> ignore
// ignore the return value of `console.log`
div [
h2 ["❤️ "; counter.el] // 👈 `counter.el`
iconButton [ // for Reactive DOM element
{|onclick = fun _ ->
counter // ③ update the Timeline
|> TLE.next ((counter |> TLE.last) + 1)
|}
icon ["thumb_up"]
]
iconButton [
{|onclick = fun _ ->
counter // ③ update the Timeline
|> TLE.next ((counter |> TLE.last) - 1)
|}
icon ["thumb_down"]
]
]
add [document.body; Counter()]
|> ignore