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

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

Issue 26967004: add @MirrorsUsed to observe/polymer/polymer_exprs pkgs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix typo in comment Created 7 years, 2 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
Index: pkg/observe/lib/src/metadata.dart
diff --git a/pkg/observe/lib/src/metadata.dart b/pkg/observe/lib/src/metadata.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f8ec5a3806f2b679a192546e69813a7ad6f274d8
--- /dev/null
+++ b/pkg/observe/lib/src/metadata.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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 observe;
+
+/**
+ * Use `@observable` to make a field automatically observable, or to indicate
+ * that a property is observable.
+ */
+const ObservableProperty observable = const ObservableProperty();
+
+/**
+ * An annotation that is used to make a property observable.
+ * Normally this is used via the [observable] constant, for example:
+ *
+ * class Monster {
+ * @observable int health;
+ * }
+ *
+ * If needed, you can subclass this to create another annotation that will also
+ * be treated as observable.
+ */
+// Note: observable properties imply reflectable.
+class ObservableProperty {
+ const ObservableProperty();
+}
+
+
+/**
+ * Use `@reflectable` to make a type or member available to reflection in the
+ * observe package. This is necessary to make the member visible to
+ * [PathObserver], or similar systems, once the code is deployed.
+ */
+const Reflectable reflectable = const Reflectable();
+
+/**
+ * An annotation that is used to make a type or member reflectable. This makes
+ * it available to [PathObserver] at runtime. For example:
+ *
+ * @reflectable
+ * class Monster extends ChangeNotifierBase {
+ * int _health;
+ * int get health => _health;
+ * ...
+ * }
+ * ...
+ * // This will work even if the code has been tree-shaken/minified:
+ * final monster = new Monster();
+ * new PathObserver(monster, 'health').changes.listen(...);
+ */
+class Reflectable {
+ const Reflectable();
+}

Powered by Google App Engine
This is Rietveld 408576698