From 0267049f29374f0114bef23a5982c930c4d2bedb Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 19 Feb 2023 13:19:05 +0100 Subject: Add pure and sequence --- src/example.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/example.ts') 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 -- cgit v1.2.3