aboutsummaryrefslogtreecommitdiff
path: root/src/example.ts
diff options
context:
space:
mode:
authorJoris2023-02-12 12:35:09 +0100
committerJoris2023-02-12 12:35:09 +0100
commit2dc698c09a32d291ea83296f2e81edf182bb6de0 (patch)
treebe990d78d2dc9ee2b00f3e751d51d88481313a28 /src/example.ts
parentd0431c7f81e20dfb77a6fe154292d6b06f433984 (diff)
downloadrx-2dc698c09a32d291ea83296f2e81edf182bb6de0.tar.gz
rx-2dc698c09a32d291ea83296f2e81edf182bb6de0.tar.bz2
rx-2dc698c09a32d291ea83296f2e81edf182bb6de0.zip
Fix double map child
The rx-base was not added at the right location, and not cleaned up.
Diffstat (limited to 'src/example.ts')
-rw-r--r--src/example.ts37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/example.ts b/src/example.ts
index c23a4eb..360bf8b 100644
--- a/src/example.ts
+++ b/src/example.ts
@@ -126,9 +126,44 @@ const chrono =
}))
])
+const doubleMapChild =
+ withVar(true, (isEven, updateIsEven) =>
+ withVar('', (search, updateSearch) => {
+ const books = [...Array(50).keys()]
+
+ const filteredBooks = isEven.flatMap(f => search.map(s =>
+ books.filter(b =>
+ (f ? b % 2 === 0 : b % 2 === 1) &&
+ (s === '' || b.toString().includes(s)))))
+
+ return [
+ checkboxComponent({
+ label: 'Even?',
+ isChecked: isEven,
+ onCheck: checked => updateIsEven(_ => checked)
+ }),
+ h(
+ 'input',
+ { oninput: (event: Event) => updateSearch(_ => (event.target as HTMLInputElement).value)
+ , style: 'margin-left: 1rem'
+ }
+ ),
+ h('hr'),
+ isEven.map(b =>
+ b
+ ? filteredBooks.map(xs => `isEven (${xs.length})`)
+ : filteredBooks.map(xs => `isOdd (${xs.length})`)
+ ),
+ h('hr'),
+ filteredBooks.map(bs => bs.map(b => h('div', b))),
+ h('hr')
+ ]
+ })
+ )
+
const view = h('main',
h('h1', 'Rx'),
- chrono
+ doubleMapChild
)
mount(view)