2 ms·
Actually, custom getters and setters exist in ES5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_sett
by straws 11y ago
Actually, custom getters and setters exist in ES5:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...
AmpersandJS, for example, implements its observable pattern in this way:
http://ampersandjs.com/learn/state http://ampersandjs.com/learn/state
That said, I don't think the pubsub/rx/observables pattern is the most optimal for UI development, since it still allows for cascading event chains. Modeling all application state as a large data structure that allows for efficient diffing — which nicely mirrors the diffing react does with both it's internal component tree and diffing with the DOM — is a much more straightforward approach. Just re-render your application 60 times a second, like a game engine, and make that process as efficient as possible.
- nulltype 11y agoThis is exactly where I am hoping reactive ui ends up. If you don't want to do 60 times a second you can render only on certain events like network call or mouseover. If you do the rendering in requestAnimationFrame you can batch things easily.