aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorJoris2023-02-18 14:30:45 +0100
committerJoris2023-02-19 13:25:29 +0100
commite1aaa513a444a32c56a9591dd92beb24e66bcf42 (patch)
tree227fd22cfe5be446955a0c5cb6109b6107632090 /README.md
parentcda836c875043572eb752a4f68368e7e1c6672f6 (diff)
downloadrx-e1aaa513a444a32c56a9591dd92beb24e66bcf42.tar.gz
rx-e1aaa513a444a32c56a9591dd92beb24e66bcf42.tar.bz2
rx-e1aaa513a444a32c56a9591dd92beb24e66bcf42.zip
Integrate update function with Var
But still don’t expose `Var`, so that it would be still passed as a Rx.
Diffstat (limited to 'README.md')
-rw-r--r--README.md11
1 files changed, 5 insertions, 6 deletions
diff --git a/README.md b/README.md
index f878b62..d2ab8a7 100644
--- a/README.md
+++ b/README.md
@@ -45,10 +45,10 @@ Counter with `-` and `+` buttons:
import { h, withVar, mount } from 'rx'
mount(
- withVar(0, (value, update) => [
+ withVar(0, value => [
value,
- h('button', { onclick: () => update(n => n - 1) }, '-'),
- h('button', { onclick: () => update(n => n + 1) }, '+')]))
+ h('button', { onclick: () => value.update(n => n - 1) }, '-'),
+ h('button', { onclick: () => value.update(n => n + 1) }, '+')]))
```
### Subscriptions
@@ -59,8 +59,8 @@ Chronometer updating every second:
import { h, withVar, mount } from 'rx'
mount(
- withVar(0, (value, update) => {
- const interval = window.setInterval(() => update(n => n + 1), 1000)
+ withVar(0, value => {
+ const interval = window.setInterval(() => value.update(n => n + 1), 1000)
return h('div',
{ onunmount: () => clearInterval(interval) },
value
@@ -82,4 +82,3 @@ argument.
## Inspiration
- https://github.com/OlivierBlanvillain/monadic-html
-- https://www.solidjs.com