Created
August 5, 2017 03:29
-
-
Save leeoniya/6149d983cd128ca6ac7c06e9dd3bd80f to your computer and use it in GitHub Desktop.
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<script src="https://cdn.rawgit.com/leeoniya/domvm/3.x-dev/dist/nano/domvm.nano.js"></script> | |
</head> | |
<body> | |
<script> | |
// http://imgur.com/a/YATqh | |
var el = domvm.defineElement; | |
function ListView() { | |
return (vm, list) => | |
el("ul", list.map(item => | |
el("li", item.val) | |
)); | |
} | |
function randInt(min, max) { | |
return Math.floor(Math.random()*(max-min+1)+min); | |
} | |
function randColor() { | |
return '#'+Math.floor(Math.random()*16777215).toString(16); | |
} | |
function makeList(qty) { | |
var items = []; | |
while (qty--) | |
items.push({val: randColor()}); | |
return items; | |
} | |
// run for 60 secs @ 100ms redraws | |
var iter = 600; | |
// leaks | |
setTimeout(function() { | |
var vm = domvm.createView(ListView, makeList(100)).mount(document.body); | |
var i = 0; | |
var it = setInterval(function() { | |
vm.update(makeList(randInt(0, 100))); | |
if (iter-- == 0) | |
clearInterval(it); | |
}, 100); | |
}, 1000); | |
/* // no leaks | |
setTimeout(function() { | |
var vm = domvm.createView(ListView, makeList(100)).mount(document.body); | |
var i = 0; | |
var it = setInterval(function() { | |
vm.update(makeList(100)); | |
if (iter-- == 0) | |
clearInterval(it); | |
}, 100); | |
}, 1000); | |
*/ | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment