Dear fellows,
For the ones among you who loves doing things in plain Javascript, how would you optimize this code while keeping it very simple ?
I don't mean performance optimizations, only suggestions to avoid memory leaks..
You can test it here : challenge
const state = {
count: 0
}
const actions = {
inc: () => {
state.count += 1;
view();
}
}
const setupEvents = () => {
document
.querySelector("button#counter")
.addEventListener("click", actions.inc);
}
const view = () => {
dividapp.innerHTML =
`
<h1>Counter ${state.count}</h1>
<button id="counter">INCR</button>
`
setupEvents();
}
view();
Crédits : the image is from BlendSwap