Created
March 4, 2016 03:02
-
-
Save freeman-lab/20a0882bb31b28865b36 to your computer and use it in GitHub Desktop.
hyperx.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vdom = require('virtual-dom') | |
var hyperx = require('hyperx') | |
var main = require('main-loop') | |
var hx = hyperx(vdom.h) | |
function list (items) { | |
return hx`<div> | |
<ul>${ | |
items.map(function (item, i) { | |
return hx`<li>${item}</li>` | |
}) | |
}</ul> | |
</div>` | |
} | |
var items = ['a', 'b', 'c'] | |
var loop = main(items, render, vdom) | |
document.body.appendChild(loop.target) | |
function render (state) { | |
return list(state) | |
} | |
setInterval(function () { | |
items.push('x-' + Math.random()) | |
loop.update(items) | |
}, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment