Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> My most complicated problems were reactive DOM elements based on nested loops and recursive components

Agreed, I've tried solving it by setting an attribute `sb-mark` which allows syncing just the branch of DOM elements that maps to that particular key in the reactive object.

This removes the need for VDOM diffing, but unless I use a `MutationObserver` external updates to marked branches will probably mess it up.

Haven't yet tested it for recursive components, it should work for nested loops.

> and it is simple but sometimes confusing

I understand what you mean, my approach has the aforementioned `sb-mark` attribute/directive which syncs primitives, lists, and objects.

I've started feeling that the convenience of having just one attribute to remember is supplanted by the confusion of its implications not being immediately apparent from context.



> This removes the need for VDOM diffing, but unless I use a `MutationObserver` external updates to marked branches will probably mess it up.

Similar in Reken. It controls all the DOM; DOM updates outside Reken will get stuff out of sync. After a model change, all managed DOM gets directly updated by a generated controller. It does check the DOM first if a textContent or attribute change is necessary. Most DOM state checks are cheap. Another optimization is that all hidden DOM trees get skipped; Great in SPA apps with multiple pages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: