Quick way to Observe multiple properties on Object

Short background:

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?

1 Like

Here is an example of subscribing to multiple properties at once and call change handler only once https://codesandbox.io/s/elegant-greider-hihl3

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)