I have a list of objects (for example, people), and I dynamically add and remove from the list. I want to run a query across the list when a certain property changes on any item
Enter: ListPathObserver
!
Add this constructor:
MyElement() {
ListPathObserver observer = new ListPathObserver(people, 'signedAgreement');
observer.changes.listen((_) => notifyProperty(this, const Symbol('signedCount')));
}
Here, observer
will fire when any person in people
has its signedAgreement
property changed.
Then, in the callback, we notify the observer system that it should go look at signedCount
.