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

Side by Side Diff: pkg/observe/lib/src/path_observer.dart

Issue 723393003: update to polymer js 0.5.1 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: final tweaks Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library observe.src.path_observer; 5 library observe.src.path_observer;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:math' show min; 9 import 'dart:math' show min;
10 10
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 obj = _getObjectProperty(obj, _segments[i]); 226 obj = _getObjectProperty(obj, _segments[i]);
227 } 227 }
228 return _setObjectProperty(obj, _segments[end], value); 228 return _setObjectProperty(obj, _segments[end], value);
229 } 229 }
230 230
231 void _iterateObjects(Object obj, void observe(obj, prop)) { 231 void _iterateObjects(Object obj, void observe(obj, prop)) {
232 if (!isValid || isEmpty) return; 232 if (!isValid || isEmpty) return;
233 233
234 int i = 0, last = _segments.length - 1; 234 int i = 0, last = _segments.length - 1;
235 while (obj != null) { 235 while (obj != null) {
236 // _segments[0] is passed to indicate that we are only observing that 236 // _segments[i] is passed to indicate that we are only observing that
237 // property of obj. See observe declaration in _ObserveSet. 237 // property of obj. See observe declaration in _ObservedSet.
238 observe(obj, _segments[0]); 238 observe(obj, _segments[i]);
239 239
240 if (i >= last) break; 240 if (i >= last) break;
241 obj = _getObjectProperty(obj, _segments[i++]); 241 obj = _getObjectProperty(obj, _segments[i++]);
242 } 242 }
243 } 243 }
244 244
245 // Dart note: it doesn't make sense to have compiledGetValueFromFn in Dart. 245 // Dart note: it doesn't make sense to have compiledGetValueFromFn in Dart.
246 } 246 }
247 247
248 248
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 858
859 void close(_Observer obs) { 859 void close(_Observer obs) {
860 if (_observers.isNotEmpty) return; 860 if (_observers.isNotEmpty) return;
861 861
862 if (_objects != null) { 862 if (_objects != null) {
863 for (var sub in _objects) sub.cancel(); 863 for (var sub in _objects) sub.cancel();
864 _objects = null; 864 _objects = null;
865 } 865 }
866 _rootObject = null; 866 _rootObject = null;
867 _rootObjectProperties = null; 867 _rootObjectProperties = null;
868 if (identical(_lastSet, this)) _lastSet = null;
868 } 869 }
869 870
870 /// Observe now takes a second argument to indicate which property of an 871 /// Observe now takes a second argument to indicate which property of an
871 /// object is being observed, so we don't trigger change notifications on 872 /// object is being observed, so we don't trigger change notifications on
872 /// changes to unrelated properties. 873 /// changes to unrelated properties.
873 void observe(Object obj, Object prop) { 874 void observe(Object obj, Object prop) {
874 if (identical(obj, _rootObject)) _rootObjectProperties.add(prop); 875 if (identical(obj, _rootObject)) _rootObjectProperties.add(prop);
875 if (obj is ObservableList) _observeStream(obj.listChanges); 876 if (obj is ObservableList) _observeStream(obj.listChanges);
876 if (obj is Observable) _observeStream(obj.changes); 877 if (obj is Observable) _observeStream(obj.changes);
877 } 878 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 if (observer._isOpen) observer._iterateObjects(observe); 920 if (observer._isOpen) observer._iterateObjects(observe);
920 } 921 }
921 922
922 for (var observer in _observers.toList(growable: false)) { 923 for (var observer in _observers.toList(growable: false)) {
923 if (observer._isOpen) observer._check(); 924 if (observer._isOpen) observer._check();
924 } 925 }
925 } 926 }
926 } 927 }
927 928
928 const int _MAX_DIRTY_CHECK_CYCLES = 1000; 929 const int _MAX_DIRTY_CHECK_CYCLES = 1000;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698