I’m using the multi observer pretty much the one described on the blog
filter: any = {
pageIndex: 0,
pageSize: 25,
query: '',
orderColumn: 'name',
orderDirection: 'asc'
};
constructor(private multiObserver: MultiObserver){
this.multiObserver.observe(this.filter, Object.getOwnPropertyNames(this.filter), () => this.filterChanged(), []);
}
filterChanged(){
// Get propertyname here which triggered the change.
this.getApplicationList();
}
That’s all working fine, but I would really like to know which one of the properties is changed, since I have need to have different behavior when the pageIndex is changed then when all the other properties are changed. Is there a way to get the property name inside the filterChanged function? Hope that someone can help out.
Thanks for the suggestion. I did look at the watch decorator, but it seems it’s not supporting array changes. I know that’s not in my example , can anybody suggest another option.
I can always create a separate observer for the page index and handle it like this for instance:
You can use the binding engine directly to observe an expression, so that you can automatically watch a property on an object, and optionally watch the length property of the sub object, which roughly equals to observing the array. An example here https://gist.dumber.app/?gist=d47cc594e7adf3f46548d9d1aaa8e2b2
Thank you very much @bigopon for your example I implemented it like below. It also got some of your binding-ext.js sample with the taskqueue, which I also need when clearing multiple filters.
Not sure whether I should use the collectionObserver or the expressionObserver, but both options work the way I want to.