Index: pkg/observe/lib/src/path_observer.dart |
diff --git a/pkg/observe/lib/src/path_observer.dart b/pkg/observe/lib/src/path_observer.dart |
index 6384f6ee4735851af401ca70b290b348f9a9b7d0..6bdc3dfc286cb61adbef65a1ff6a54177e6bafa3 100644 |
--- a/pkg/observe/lib/src/path_observer.dart |
+++ b/pkg/observe/lib/src/path_observer.dart |
@@ -184,15 +184,28 @@ class PathObserver extends ChangeNotifier { |
void _observeIndex(int i) { |
final object = _values[i]; |
- if (object is Observable) { |
+ final segment = _segments[i]; |
+ if (segment is int) { |
+ if (object is ObservableList) { |
+ _subs[i] = object.listChanges.listen((List<ListChangeRecord> records) { |
+ for (var record in records) { |
+ if (record.indexChanged(segment)) { |
+ _updateObservedValues(start: i); |
+ return; |
+ } |
+ } |
+ }); |
+ } |
+ } else if (object is Observable) { |
// TODO(jmesserly): rather than allocating a new closure for each |
// property, we could try and have one for the entire path. However we'd |
// need to do a linear scan to find the index as soon as we got a change. |
// Also we need to fix ListChangeRecord and MapChangeRecord to contain |
// the target. Not sure if it's worth it. |
+ |
_subs[i] = object.changes.listen((List<ChangeRecord> records) { |
for (var record in records) { |
- if (_changeRecordMatches(record, _segments[i])) { |
+ if (_changeRecordMatches(record, segment)) { |
_updateObservedValues(start: i); |
return; |
} |
@@ -203,9 +216,6 @@ class PathObserver extends ChangeNotifier { |
} |
bool _changeRecordMatches(record, key) { |
- if (record is ListChangeRecord) { |
- return key is int && (record as ListChangeRecord).indexChanged(key); |
- } |
if (record is PropertyChangeRecord) { |
return (record as PropertyChangeRecord).name == key; |
} |