OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Support for observing changes in model-view architectures. | 6 * Support for observing changes in model-view architectures. |
7 * | 7 * |
8 * **Warning:** This library is experimental, and APIs are subject to change. | 8 * **Warning:** This library is experimental, and APIs are subject to change. |
9 * | 9 * |
10 * This library is used to observe changes to [Observable] types. It also | 10 * This library is used to observe changes to [Observable] types. It also |
(...skipping 27 matching lines...) Expand all Loading... |
38 * } | 38 * } |
39 * | 39 * |
40 * A more sophisticated approach is to implement the change notification | 40 * A more sophisticated approach is to implement the change notification |
41 * manually. This avoids the potentially expensive [Observable.dirtyCheck] | 41 * manually. This avoids the potentially expensive [Observable.dirtyCheck] |
42 * operation, but requires more work in the object: | 42 * operation, but requires more work in the object: |
43 * | 43 * |
44 * class Monster extends Unit with ChangeNotifierMixin { | 44 * class Monster extends Unit with ChangeNotifierMixin { |
45 * int _health = 100; | 45 * int _health = 100; |
46 * get health => _health; | 46 * get health => _health; |
47 * set health(val) { | 47 * set health(val) { |
48 * _health = notifyPropertyChange(const Symbol('health'), _health, val); | 48 * _health = notifyPropertyChange(#health, _health, val); |
49 * } | 49 * } |
50 * | 50 * |
51 * void damage(int amount) { | 51 * void damage(int amount) { |
52 * print('$this takes $amount damage!'); | 52 * print('$this takes $amount damage!'); |
53 * health -= amount; | 53 * health -= amount; |
54 * } | 54 * } |
55 * | 55 * |
56 * toString() => 'Monster with $health hit points'; | 56 * toString() => 'Monster with $health hit points'; |
57 * } | 57 * } |
58 * | 58 * |
(...skipping 27 matching lines...) Expand all Loading... |
86 part 'src/change_notifier.dart'; | 86 part 'src/change_notifier.dart'; |
87 part 'src/change_record.dart'; | 87 part 'src/change_record.dart'; |
88 part 'src/compound_binding.dart'; | 88 part 'src/compound_binding.dart'; |
89 part 'src/list_path_observer.dart'; | 89 part 'src/list_path_observer.dart'; |
90 part 'src/observable.dart'; | 90 part 'src/observable.dart'; |
91 part 'src/observable_box.dart'; | 91 part 'src/observable_box.dart'; |
92 part 'src/observable_list.dart'; | 92 part 'src/observable_list.dart'; |
93 part 'src/observable_map.dart'; | 93 part 'src/observable_map.dart'; |
94 part 'src/path_observer.dart'; | 94 part 'src/path_observer.dart'; |
95 part 'src/to_observable.dart'; | 95 part 'src/to_observable.dart'; |
OLD | NEW |