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(); |
+} |