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

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

Issue 14732003: Implement Model-Driven-Views spec for Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comment tweaks Created 7 years, 7 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 | « no previous file | pkg/observe/lib/src/observable_box.dart » ('j') | pkg/observe/lib/src/observable_list.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/observe.dart
diff --git a/pkg/observe/lib/observe.dart b/pkg/observe/lib/observe.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3ee6dc70b8d669860d69be71ba7668394b26c59e
--- /dev/null
+++ b/pkg/observe/lib/observe.dart
@@ -0,0 +1,63 @@
+// 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.
+
+/**
+ * *Warning*: this library is experimental, and APIs are subject to change.
+ *
+ * This library is used to observe changes to [Observable] types. It also
+ * has helpers to implement [Observable] objects.
+ *
+ * For example:
+ *
+ * class Monster extends Object with ObservableMixin {
+ * static const _HEALTH = const Symbol('health');
+ *
+ * int _health = 100;
+ * get health => _health;
+ * set health(value) {
+ * _health = notifyChange(_HEALTH, _health, value);
+ * }
+ *
+ * void damage(int amount) {
+ * print('$this takes $amount damage!');
+ * health -= amount;
+ * }
+ *
+ * toString() => 'Monster with $health hit points';
+ *
+ * // These methods are temporary until dart2js supports mirrors.
+ * getValueWorkaround(key) {
+ * if (key == _HEALTH) return health;
+ * return null;
+ * }
+ * setValueWorkaround(key, val) {
+ * if (key == _HEALTH) health = val;
+ * }
+ * }
+ *
+ * main() {
+ * var obj = new Monster();
+ * obj.changes.listen((records) {
+ * print('Changes to $obj were: $records');
+ * });
+ * // Schedules asynchronous delivery of these changes
+ * obj.damage(10);
+ * obj.damage(20);
+ * print('done!');
+ * }
+ */
+library observe;
+
+// Import the observe implementation library. It contains the types that are
+// required to implement Model-Driven-Views in dart:html. Use package:observe
+// (this package) if you need this functionality
+// DO NOT import observe_impl in your code; it may break unpredictably.
+import 'dart:observe_impl';
+
+// Re-export the observe implementation
+export 'dart:observe_impl';
+
+part 'src/observable_box.dart';
+part 'src/observable_list.dart';
+part 'src/observable_map.dart';
« no previous file with comments | « no previous file | pkg/observe/lib/src/observable_box.dart » ('j') | pkg/observe/lib/src/observable_list.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698