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

Side by Side Diff: tools/dom/src/PathObserver.dart

Issue 16131003: Reapply "Active stream subscriptions". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Patch from sgjesse fixing file descriptor error. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/standalone.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of html; 5 part of html;
6 6
7 // This code is inspired by ChangeSummary: 7 // This code is inspired by ChangeSummary:
8 // https://github.com/rafaelw/ChangeSummary/blob/master/change_summary.js 8 // https://github.com/rafaelw/ChangeSummary/blob/master/change_summary.js
9 // ...which underlies MDV. Since we don't need the functionality of 9 // ...which underlies MDV. Since we don't need the functionality of
10 // ChangeSummary, we just implement what we need for data bindings. 10 // ChangeSummary, we just implement what we need for data bindings.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * Observes [path] on [object] for changes. This returns an object that can be 65 * Observes [path] on [object] for changes. This returns an object that can be
66 * used to get the changes and get/set the value at this path. 66 * used to get the changes and get/set the value at this path.
67 * See [PathObserver.values] and [PathObserver.value]. 67 * See [PathObserver.values] and [PathObserver.value].
68 */ 68 */
69 PathObserver(this.object, String path) 69 PathObserver(this.object, String path)
70 : path = path, _isValid = _isPathValid(path) { 70 : path = path, _isValid = _isPathValid(path) {
71 71
72 // TODO(jmesserly): if the path is empty, or the object is! Observable, we 72 // TODO(jmesserly): if the path is empty, or the object is! Observable, we
73 // can optimize the PathObserver to be more lightweight. 73 // can optimize the PathObserver to be more lightweight.
74 74
75 _values = new StreamController(onListen: _observe, onCancel: _unobserve); 75 _values = new StreamController.multiplex(onListen: _observe,
76 onCancel: _unobserve);
76 77
77 if (_isValid) { 78 if (_isValid) {
78 var segments = []; 79 var segments = [];
79 for (var segment in path.trim().split('.')) { 80 for (var segment in path.trim().split('.')) {
80 if (segment == '') continue; 81 if (segment == '') continue;
81 var index = int.parse(segment, onError: (_) {}); 82 var index = int.parse(segment, onError: (_) {});
82 segments.add(index != null ? index : new Symbol(segment)); 83 segments.add(index != null ? index : new Symbol(segment));
83 } 84 }
84 85
85 // Create the property observer linked list. 86 // Create the property observer linked list.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 278
278 final _spacesRegExp = new RegExp(r'\s'); 279 final _spacesRegExp = new RegExp(r'\s');
279 280
280 bool _isPathValid(String s) { 281 bool _isPathValid(String s) {
281 s = s.replaceAll(_spacesRegExp, ''); 282 s = s.replaceAll(_spacesRegExp, '');
282 283
283 if (s == '') return true; 284 if (s == '') return true;
284 if (s[0] == '.') return false; 285 if (s[0] == '.') return false;
285 return _pathRegExp.hasMatch(s); 286 return _pathRegExp.hasMatch(s);
286 } 287 }
OLDNEW
« no previous file with comments | « tests/standalone/standalone.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698