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

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

Issue 357003002: Fix list_path_observer, temporarily add a test for it, but we'll likely remove (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « no previous file | pkg/observe/test/list_path_observer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/src/list_path_observer.dart
diff --git a/pkg/observe/lib/src/list_path_observer.dart b/pkg/observe/lib/src/list_path_observer.dart
index 44b2759d47f427e362e57e8539d76235be49aae9..bab01c230fd5d121ae9ef534fe2fb8d9d27f9a49 100644
--- a/pkg/observe/lib/src/list_path_observer.dart
+++ b/pkg/observe/lib/src/list_path_observer.dart
@@ -16,7 +16,6 @@ class ListPathObserver<E, P> extends ChangeNotifier {
final ObservableList<E> list;
final String _itemPath;
final List<PathObserver> _observers = <PathObserver>[];
- final List<StreamSubscription> _subs = <StreamSubscription>[];
StreamSubscription _sub;
bool _scheduled = false;
Iterable<P> _value;
@@ -40,8 +39,8 @@ class ListPathObserver<E, P> extends ChangeNotifier {
void dispose() {
if (_sub != null) _sub.cancel();
- _subs.forEach((s) => s.cancel());
- _subs.clear();
+ _observers.forEach((o) => o.close());
+ _observers.clear();
}
void _reduce() {
@@ -61,15 +60,13 @@ class ListPathObserver<E, P> extends ChangeNotifier {
for (int i = 0; i < lengthAdjust; i++) {
int len = _observers.length;
var pathObs = new PathObserver(list, '$len.$_itemPath');
- _subs.add(pathObs.changes.listen(_scheduleReduce));
+ pathObs.open(_scheduleReduce);
_observers.add(pathObs);
}
} else if (lengthAdjust < 0) {
for (int i = 0; i < -lengthAdjust; i++) {
- _subs.removeLast().cancel();
+ _observers.removeLast().close();
}
- int len = _observers.length;
- _observers.removeRange(len + lengthAdjust, len);
}
}
}
« no previous file with comments | « no previous file | pkg/observe/test/list_path_observer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698