aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md16
1 files changed, 12 insertions, 4 deletions
diff --git a/README.md b/README.md
index 41303b0..2354819 100644
--- a/README.md
+++ b/README.md
@@ -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?