Do we really data-bindings, directives, observables, streams... for building Web UI ?
artydev
Posted on October 11, 2020
I just discovered the library diffHTML
And I have adapted one of the sample.
Look a the code below, there is no databindings, no directives, the UI is constantly refreshed at highest rate possible, like in a game loop;
Could this be a viable solution ?
Tell me what you think ?
You can test it here : diffHTML
(function () {
const {innerHTML, html} = window.diff
const state = {
name: "Anonymous",
email: "nobody@nowhere.com"
}
const actions = {
changeName: (e) => state.name = e.target.value,
changeEmail: (e) => state.email = e.target.value
}
function render() {
innerHTML(window.scene, html`
<style>
input {
margin-bottom: 10px;
display: block;
}
</style>
<h2>
Hello ${state.name} <br /> Your email is : ${state.email}
</h2>
Name : <input oninput="${actions.changeName}"/>
Email : <input oninput="${actions.changeEmail}"/>
`);
requestAnimationFrame(render);
}
render();
})();
💖 💪 🙅 🚩
artydev
Posted on October 11, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.