git ssb

1+

Matt McKegg / mutant



Tree: e75defac47630de9da141ca0ca89cba54a030464

Files: e75defac47630de9da141ca0ca89cba54a030464 / test / dom.js

820 bytesRaw
1var Struct = require('../struct')
2var send = require('../send')
3var h = require('../html-element')
4
5var state = Struct({
6 text: 'Test',
7 color: 'red',
8 value: 0
9})
10
11var element = h('div.cool', {
12 classList: ['cool', state.text],
13 style: {
14 'background-color': state.color
15 }
16}, [
17 h('div', [
18 state.text, ' ', state.value, ' ', h('strong', 'test')
19 ]),
20 h('div', [
21 h('button', {
22 'ev-click': send(state.color.set, 'blue')
23 }, 'Change color')
24 ])
25])
26
27setTimeout(function () {
28 state.text.set('Another value')
29}, 5000)
30
31setInterval(function () {
32 state.value.set(state.value() + 1)
33}, 1000)
34
35setInterval(function () {
36 // bulk update state
37 state.set({
38 text: 'Retrieved from server (not really)',
39 color: '#FFEECC',
40 value: 1337
41 })
42}, 10000)
43
44document.body.appendChild(element)
45

Built with git-ssb-web