Use changes
to listen for any changes to an observable object. You can put this into the created()
lifecycle callback:
class Example extends PolymerElement with ObservableMixin {
final ObservableList masterList = toObservable([]);
created() {
masterList.changes.listen((List<ChangeRecord> changes) {
notifyProperty(this, const Symbol('subList'));
}
}
List get subList => masterList.where((item) => item.isDone);
}
It's important to remember that changes
is watching for additions and removals from the masterList
. You probably don't want the typical bindProperty
pattern because that just watches for changes to the variable itself (if the variable is set to a different object, then bindProperty will run).