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

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

Issue 178683003: [observe] use consistent comment style (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/html.dart ('k') | pkg/observe/lib/src/bind_property.dart » ('j') | no next file with comments »
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
index 1dd83b866d9f8e361ed75a914dbf66429b86998f..3b7c138fe3f9150d3dc2fe1e704237ff1595c97f 100644
--- a/pkg/observe/lib/observe.dart
+++ b/pkg/observe/lib/observe.dart
@@ -2,79 +2,77 @@
// 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.
-/**
- * Support for observing changes in model-view architectures.
- *
- * **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 make implementing and using [Observable] objects easy.
- *
- * You can provide an observable object in two ways. The simplest way is to
- * use dirty checking to discover changes automatically:
- *
- * class Monster extends Unit with Observable {
- * @observable int health = 100;
- *
- * void damage(int amount) {
- * print('$this takes $amount damage!');
- * health -= amount;
- * }
- *
- * toString() => 'Monster with $health hit points';
- * }
- *
- * main() {
- * var obj = new Monster();
- * obj.changes.listen((records) {
- * print('Changes to $obj were: $records');
- * });
- * // No changes are delivered until we check for them
- * obj.damage(10);
- * obj.damage(20);
- * print('dirty checking!');
- * Observable.dirtyCheck();
- * print('done!');
- * }
- *
- * A more sophisticated approach is to implement the change notification
- * manually. This avoids the potentially expensive [Observable.dirtyCheck]
- * operation, but requires more work in the object:
- *
- * class Monster extends Unit with ChangeNotifier {
- * int _health = 100;
- * @reflectable get health => _health;
- * @reflectable set health(val) {
- * _health = notifyPropertyChange(#health, _health, val);
- * }
- *
- * void damage(int amount) {
- * print('$this takes $amount damage!');
- * health -= amount;
- * }
- *
- * toString() => 'Monster with $health hit points';
- * }
- *
- * 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!');
- * }
- *
- * *Note*: it is good practice to keep `@reflectable` annotation on
- * getters/setters so they are accessible via reflection. This will preserve
- * them from tree-shaking. You can also put this annotation on the class and it
- * preserve all of its members for reflection.
- *
- * [Tools](https://www.dartlang.org/polymer-dart/) exist to convert the first
- * form into the second form automatically, to get the best of both worlds.
- */
+/// Support for observing changes in model-view architectures.
+///
+/// **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 make implementing and using [Observable] objects easy.
+///
+/// You can provide an observable object in two ways. The simplest way is to
+/// use dirty checking to discover changes automatically:
+///
+/// class Monster extends Unit with Observable {
+/// @observable int health = 100;
+///
+/// void damage(int amount) {
+/// print('$this takes $amount damage!');
+/// health -= amount;
+/// }
+///
+/// toString() => 'Monster with $health hit points';
+/// }
+///
+/// main() {
+/// var obj = new Monster();
+/// obj.changes.listen((records) {
+/// print('Changes to $obj were: $records');
+/// });
+/// // No changes are delivered until we check for them
+/// obj.damage(10);
+/// obj.damage(20);
+/// print('dirty checking!');
+/// Observable.dirtyCheck();
+/// print('done!');
+/// }
+///
+/// A more sophisticated approach is to implement the change notification
+/// manually. This avoids the potentially expensive [Observable.dirtyCheck]
+/// operation, but requires more work in the object:
+///
+/// class Monster extends Unit with ChangeNotifier {
+/// int _health = 100;
+/// @reflectable get health => _health;
+/// @reflectable set health(val) {
+/// _health = notifyPropertyChange(#health, _health, val);
+/// }
+///
+/// void damage(int amount) {
+/// print('$this takes $amount damage!');
+/// health -= amount;
+/// }
+///
+/// toString() => 'Monster with $health hit points';
+/// }
+///
+/// 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!');
+/// }
+///
+/// *Note*: it is good practice to keep `@reflectable` annotation on
+/// getters/setters so they are accessible via reflection. This will preserve
+/// them from tree-shaking. You can also put this annotation on the class and it
+/// preserve all of its members for reflection.
+///
+/// [Tools](https://www.dartlang.org/polymer-dart/) exist to convert the first
+/// form into the second form automatically, to get the best of both worlds.
library observe;
// This library contains code ported from observe-js:
« no previous file with comments | « pkg/observe/lib/html.dart ('k') | pkg/observe/lib/src/bind_property.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698