From e1aaa513a444a32c56a9591dd92beb24e66bcf42 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 18 Feb 2023 14:30:45 +0100 Subject: Integrate update function with Var But still don’t expose `Var`, so that it would be still passed as a Rx. --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'README.md') 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 -- cgit v1.2.3