3 ms·
Been working on this off and on for the last 15 years. Pretty much ended up where I started. Except the newer JS syntax is nicer than in 2005. Control: cont
by dpweb 6y ago
Been working on this off and on for the last 15 years. Pretty much ended up where I started. Except the newer JS syntax is nicer than in 2005.
Control:
controls.hello = e =>
e.innerHTML = `Hello ${e.getAtttribute('x-who')}`
<hello x-who='world' />
"Framework" just cycles thru the dom and calls control def with the element as the param.
To handle data, there's a window.data object, which is global data for the app.
Its a proxy object. So when window.data is changed, for instance from the results of a fetch,
any controls that specify that key - their set() function is called.
<button onclick='data.count++'>Click me</button>
<counter x-datafield='count'></counter>
data.count = 0
controls.counter = e =>
e.set = () => e.innerHTML = data.count