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

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

Issue 17552019: Reorganize mdv and observe packages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/observe/lib/src/observable_map.dart ('k') | pkg/observe/pubspec.yaml » ('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/sdk/lib/mdv_observe_impl/path_observer.dart b/pkg/observe/lib/src/path_observer.dart
similarity index 93%
rename from sdk/lib/mdv_observe_impl/path_observer.dart
rename to pkg/observe/lib/src/path_observer.dart
index 5d3fae443390f2a301fb7f814f20add008e10b97..7f26c3958afc60f6e0f57436bd0e56d931125899 100644
--- a/sdk/lib/mdv_observe_impl/path_observer.dart
+++ b/pkg/observe/lib/src/path_observer.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of dart.mdv_observe_impl;
+part of observe;
// This code is inspired by ChangeSummary:
// https://github.com/rafaelw/ChangeSummary/blob/master/change_summary.js
@@ -171,7 +171,6 @@ class PathObserver {
}
}
-// TODO(jmesserly): these should go away in favor of mirrors!
_getObjectProperty(object, property) {
if (object is List && property is int) {
if (property >= 0 && property < object.length) {
@@ -181,27 +180,45 @@ _getObjectProperty(object, property) {
}
}
- // TODO(jmesserly): what about length?
- if (object is Map) return object[property];
+ if (property is Symbol) {
+ var mirror = reflect(object);
+ try {
+ return mirror.getField(property).reflectee;
+ } catch (e) {}
+ }
- if (object is Observable) return object.getValueWorkaround(property);
+ if (object is Map) {
+ return object[property];
+ }
return null;
}
bool _setObjectProperty(object, property, value) {
if (object is List && property is int) {
+ if (property >= 0 && property < object.length) {
+ object[property] = value;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ if (property is Symbol) {
+ var mirror = reflect(object);
+ try {
+ mirror.setField(property, value);
+ return true;
+ } catch (e) {}
+ }
+
+ if (object is Map) {
object[property] = value;
- } else if (object is Map) {
- object[property] = value;
- } else if (object is Observable) {
- (object as Observable).setValueWorkaround(property, value);
- } else {
- return false;
+ return true;
}
- return true;
-}
+ return false;
+}
class _PropertyObserver {
final PathObserver _path;
« no previous file with comments | « pkg/observe/lib/src/observable_map.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698