Reactive data (feature)
See original GitHub issueReef looks good! I love anything that can do heavy lifting without loads of bloat, dependencies, and compiling.
I note that—and I think I’m correct in saying—an event is emitted when the render()
function is used. But it would seem no event or ‘reaction’ occurs when the data itself is changed.
I read https://vuejs.org/v2/guide/reactivity.html and it appears Vue does this by converting the basic data
object into getters and setters which emit events whenever the values change. I’ve been playing with something similar which just wraps assignment in functions to emit a customEvent
: no need for setters or getters, and works with adding properties.
I solved this in just under 1K uncompressed: https://gist.github.com/Heydon/9de1a8b55dd1448281fad013503a5b7a. But I wonder if there is a better way. Have you considered adding this facility, so that authors could (conditionally) subscribe to changes in the data object?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top GitHub Comments
Change of heart! This feature is coming in the very near future.
It will work like React’s
setState()
feature, allowing you to pass in partial or complete state changes and have them automatically re-rendered into the DOM. I’m also adding a getter function to let you get a cloned version of the existing state.Annnnnnddddd data reactivity is here! https://github.com/cferdinandi/reef/#state-management