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

Side by Side Diff: sdk/lib/mdv_observe_impl/path_observer.dart

Issue 17434008: Move PathObserver to mdv_observe package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « sdk/lib/mdv_observe_impl/mdv_observe_impl.dart ('k') | tests/html/path_observer_test.dart » ('j') | 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 dart.mdv_observe_impl;
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.
11 // This allows our implementation to be much simpler. 11 // This allows our implementation to be much simpler.
12 12
13 // TODO(jmesserly): should we make these types stronger, and require 13 // TODO(jmesserly): should we make these types stronger, and require
14 // Observable objects? Currently, it is fine to say something like: 14 // Observable objects? Currently, it is fine to say something like:
15 // var path = new PathObserver(123, ''); 15 // var path = new PathObserver(123, '');
(...skipping 17 matching lines...) Expand all
33 * `foo.bar.baz`. 33 * `foo.bar.baz`.
34 * 34 *
35 * When the [values] stream is being listened to, this will observe changes to 35 * When the [values] stream is being listened to, this will observe changes to
36 * the object and any intermediate object along the path, and send [values] 36 * the object and any intermediate object along the path, and send [values]
37 * accordingly. When all listeners are unregistered it will stop observing 37 * accordingly. When all listeners are unregistered it will stop observing
38 * the objects. 38 * the objects.
39 * 39 *
40 * This class is used to implement [Node.bind] and similar functionality. 40 * This class is used to implement [Node.bind] and similar functionality.
41 */ 41 */
42 // TODO(jmesserly): find a better home for this type. 42 // TODO(jmesserly): find a better home for this type.
43 @Experimental
44 class PathObserver { 43 class PathObserver {
45 /** The object being observed. */ 44 /** The object being observed. */
46 final object; 45 final object;
47 46
48 /** The path string. */ 47 /** The path string. */
49 final String path; 48 final String path;
50 49
51 /** True if the path is valid, otherwise false. */ 50 /** True if the path is valid, otherwise false. */
52 final bool _isValid; 51 final bool _isValid;
53 52
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 278
280 final _spacesRegExp = new RegExp(r'\s'); 279 final _spacesRegExp = new RegExp(r'\s');
281 280
282 bool _isPathValid(String s) { 281 bool _isPathValid(String s) {
283 s = s.replaceAll(_spacesRegExp, ''); 282 s = s.replaceAll(_spacesRegExp, '');
284 283
285 if (s == '') return true; 284 if (s == '') return true;
286 if (s[0] == '.') return false; 285 if (s[0] == '.') return false;
287 return _pathRegExp.hasMatch(s); 286 return _pathRegExp.hasMatch(s);
288 } 287 }
OLDNEW
« no previous file with comments | « sdk/lib/mdv_observe_impl/mdv_observe_impl.dart ('k') | tests/html/path_observer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698