Last active
May 14, 2017 11:14
-
-
Save WebReflection/113b136c3a0e49b2ac96c6d9f55615e6 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
"use strict"; | |
class Foo { | |
constructor(root) { | |
this.render = hyperHTML.bind(root); | |
this.state = Introspected({}, $ctrl => this.update($ctrl)); | |
this.state.items = [ | |
{ id: 1, text: "foo" }, | |
{ id: 2, text: "bar" }, | |
{ id: 3, text: "baz" } | |
]; | |
} | |
update($ctrl) { | |
this.render` | |
<ul>${$ctrl.items.map(item => hyperHTML.wire(item)` | |
<li> ${item.id} / ${item.text} </li> | |
`)}</ul> | |
`; | |
} | |
} | |
const foo = new Foo(document.body); | |
setTimeout(() => { | |
foo.state.items.push({ id: 4, text: "minions" }); | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have updated
hyperHTML
with a nice feature such multi wire per same object and by IDs.You can see a live example of your use-case in this page.
I have also added the ability to set object with
handleEvent
methods as events to simplify, and reuse, as many callbacks per component as possible.