Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: pkg/observe/lib/src/path_observer.dart

Issue 53743002: introduce ObservableList.listChanges to keep list changes separate from property changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/observe/lib/src/observable_list.dart ('k') | pkg/observe/test/list_change_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « pkg/observe/lib/src/observable_list.dart ('k') | pkg/observe/test/list_change_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698