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

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

Issue 24149003: Port of github.com/polymer/polymer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 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/bind_property.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/src/observable.dart
diff --git a/pkg/observe/lib/src/observable.dart b/pkg/observe/lib/src/observable.dart
index d39f84ab96eebd1e6bc73f9bbf921fd5acf71a21..c5c56abe1fc208ce9db21ce968e40af29ad36ad2 100644
--- a/pkg/observe/lib/src/observable.dart
+++ b/pkg/observe/lib/src/observable.dart
@@ -7,7 +7,7 @@ part of observe;
/**
* Use `@observable` to make a field automatically observable.
*/
-const Object observable = const _ObservableAnnotation();
+const ObservableProperty observable = const ObservableProperty();
/**
* Interface representing an observable object. This is used by data in
@@ -124,7 +124,7 @@ abstract class ObservableMixin implements Observable {
if (field.isFinal || field.isStatic || field.isPrivate) continue;
for (var meta in field.metadata) {
- if (identical(observable, meta.reflectee)) {
+ if (meta.reflectee is ObservableProperty) {
var name = field.simpleName;
// Note: since this is a field, getting the value shouldn't execute
// user code, so we don't need to worry about errors.
@@ -220,12 +220,16 @@ _notifyPropertyChange(Observable obj, Symbol field, Object oldValue,
/**
- * The type of the `@observable` annotation.
+ * An annotation that is used to make a property observable.
+ * Normally this is used via the [observable] constant, for example:
*
- * Library private because you should be able to use the [observable] field
- * to get the one and only instance. We could make it public though, if anyone
- * needs it for some reason.
+ * class Monster {
+ * @observable int health;
+ * }
+ *
+ * If needed, you can subclass this to create another annotation that will also
+ * be treated as observable.
*/
-class _ObservableAnnotation {
- const _ObservableAnnotation();
+class ObservableProperty {
+ const ObservableProperty();
}
« no previous file with comments | « pkg/observe/lib/src/bind_property.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698