Skip to content

Commit aa06f9f

Browse files
committed
update examples
1 parent 703bbe0 commit aa06f9f

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ and also ``on(node, { click: e => {} }, =options)``.
9595
### Click Counting Button
9696

9797
```js
98-
const {component, componentReady, dom: {h1}, $} = rilti
98+
const { component, componentReady, dom: { h1 }} = rilti
9999

100100
component('counter-button', {
101101
bind: {
102102
count: {
103-
// set host.innerText to val on create and changes
104-
key: 'innerText',
103+
key: 'clicks:innerText',
105104
val: 0,
106-
view: count => `clicks: ${count}`
105+
views: {
106+
clicks: count => `clicks: ${count}`
107+
}
107108
}
108109
},
109110
on: {
@@ -113,7 +114,7 @@ component('counter-button', {
113114

114115
componentReady('body > counter-button', el => {
115116
const tellEm = h1['tell-em'](`You just won't stop clicking huh?`)
116-
el.$count.observe(count => {
117+
el.$count.on.change(count => {
117118
if (count > 20 && count < 40 && !tellEm.mounted) tellEm.render('body')
118119
else if (count > 40 && count < 100) tellEm.txt += ' Seriously? '
119120
else if (count > 100) tellEm.txt = 'What? You want a prize or something?'
@@ -126,17 +127,21 @@ componentReady('body > counter-button', el => {
126127
```js
127128
const {databind, dom: {button, div, h1}} = rilti
128129

129-
div({
130+
div.multicounter({
130131
render: 'body', // <- apend to <body> on load
131132
bind: {
132133
count: {
133134
val: 0,
134-
view: count => `current count is at: ${count}`
135+
views: {
136+
display: count => `current count is at: ${count}`
137+
}
135138
}
136139
}
137140
},
138141
host => [ // <com-po-nents> bind natively, other elements bind to el.bind['$bind/bindValue']
139-
h1(host.bind.$count.text),
142+
h1(
143+
host.bind.$count.text('display')
144+
),
140145
button({onclick: e => ++host.bind.count}, '+'),
141146
button({onclick: e => --host.bind.count}, '-')
142147
]
@@ -150,23 +155,23 @@ rilti.dom.div.pointer_tracker({
150155
css: {width: '300px', height: '300px'},
151156
bind: {
152157
pointer: {
153-
key: 'innerText',
154-
val: {
155-
x: 0,
156-
y: 0,
158+
key: 'location:innerText',
159+
val: {x: 0, y: 0},
160+
views: {
161+
location: ({x, y}) => `Pointer is at (${x}x, ${y}y)`
157162
},
158-
view: ({x, y}) => `
159-
The pointer is at (${x.toFixed(2)}x, ${y.toFixed(2)}y)
160-
`
163+
change: ({x, y}) => ({x: x.toFixed(2), y: y.toFixed(2)})
161164
}
162165
},
163-
onpointermove: ({x, y}, el) => el.bind.$pointer({x, y})
166+
onpointermove ({x, y}, el) {
167+
el.bind.pointer = {x, y}
168+
}
164169
})
165170
```
166171
the above produces this:
167172
```html
168173
<div class="pointer-tracker" style="width: 300px; height: 300px;">
169-
The pointer is at (0x, 0y)
174+
Pointer is at (0x, 0y)
170175
</div>
171176
```
172177

0 commit comments

Comments
 (0)