diff options
author | Joris | 2025-04-16 09:20:45 +0200 |
---|---|---|
committer | Joris | 2025-04-16 09:20:45 +0200 |
commit | 9cac1c7bf46f0fee7392ec47ad445fe487bf6ef4 (patch) | |
tree | 46d19a695634a464c54f5ea04ab2ba5b69ccc7d3 /README.md | |
parent | 0561c607d8dbb4e927897066ceccd45269a45cbd (diff) |
Add interface to pick example to run
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -21,7 +21,7 @@ Limitations: ```typescript import { h, mount } from 'rx' -mount(h('div', 'Hello World!')) +mount(document.body, h('div', 'Hello World!')) ``` ### Attributes @@ -29,7 +29,7 @@ mount(h('div', 'Hello World!')) ```typescript import { h, mount } from 'rx' -mount(h('button', +mount(document.body, h('button', { className: 'g-Button', color: 'green', onclick: () => console.log('Clicked!') @@ -45,6 +45,7 @@ Counter with `-` and `+` buttons: import { h, withState, mount } from 'rx' mount( + document.body, withState(0, value => [ value, h('button', { onclick: () => value.update(n => n - 1) }, '-'), @@ -59,10 +60,11 @@ Chronometer updating every second: import { h, withState, mount } from 'rx' mount( + document.body, withState(0, value => { const interval = window.setInterval(() => value.update(n => n + 1), 1000) return h('div', - { onunmount: () => clearInterval(interval) }, + { onunmount: () => clearInterval(interval) }, value ) })) @@ -72,9 +74,15 @@ mount( `onmount` is available as well. Those functions can take the `element` as an argument. +## Examples + +Run examples with: + + nix develop --command bin/dev-server + ## Ideas -- API: +- API: - Rx debounce, filter, - Routeur with sub-page support. - Optimization: store intermediate rx instead of recomputing each time for multiple subscribers? |