diff options
author | Joris | 2023-02-18 14:30:45 +0100 |
---|---|---|
committer | Joris | 2023-02-19 13:25:29 +0100 |
commit | e1aaa513a444a32c56a9591dd92beb24e66bcf42 (patch) | |
tree | 227fd22cfe5be446955a0c5cb6109b6107632090 /README.md | |
parent | cda836c875043572eb752a4f68368e7e1c6672f6 (diff) |
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.md | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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 |