I’m implementing a vis-timeline, and want to dynamically load data onRangeChanged. Simple, BUT not very performant, calling for a thrtolle/debounce. Also not to taxing, but trying to do so cleanly, I wanted to use Aurelias built-in propertyObserver, and listen on a simple range object (two properties only, start, end).
Now this can be easily done with the verbose bindingEngine approach… but is there a way to keep it smaller with something similar to the @observable decorator?
The difference compared to observable is we need to queue the callback to next tick, to ensure all the changes has been in place. You can have a look at the method generateRandomName to see this (callback needs to be called after both first/last names have been changed)
I would say that observing all properties of an object might be expensive and should be done only in special circumstances. And to that end, the solution from @bigopon should work quite nicely.
If the need of observation is limited to a specific are of the app, then you can have a proxy-based solution (refer: Proxy - JavaScript | MDN). Otherwise, it might be better to stick to the individual property observation.