aboutsummaryrefslogtreecommitdiff
path: root/src/example.ts
diff options
context:
space:
mode:
authorJoris2023-02-19 13:19:05 +0100
committerJoris2023-02-19 13:25:52 +0100
commit0267049f29374f0114bef23a5982c930c4d2bedb (patch)
tree157cc1315e36723a2c7ef0f949e2136732d7e6bf /src/example.ts
parent8b84a732436fc6c84ce4b912b548648eb91c9312 (diff)
Add pure and sequence
Diffstat (limited to 'src/example.ts')
-rw-r--r--src/example.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/example.ts b/src/example.ts
index 5ff3fba..229d3a0 100644
--- a/src/example.ts
+++ b/src/example.ts
@@ -161,6 +161,30 @@ const doubleMapChild =
})
)
+const seq =
+ withState(0, a =>
+ withState(0, b =>
+ withState(0, c => [
+ counterComponent({
+ value: a,
+ onSub: () => a.update(n => n - 1),
+ onAdd: () => a.update(n => n + 1)
+ }),
+ counterComponent({
+ value: b,
+ onSub: () => b.update(n => n - 1),
+ onAdd: () => b.update(n => n + 1)
+ }),
+ counterComponent({
+ value: c,
+ onSub: () => c.update(n => n - 1),
+ onAdd: () => c.update(n => n + 1)
+ }),
+ sequence2([a, b, c]).map(xs => xs.reduce((a, b) => a + b, 0))
+ ])
+ )
+ )
+
const view = h('main',
h('h1', 'Rx'),
chrono