| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * *Warning*: this library is experimental, and APIs are subject to change. |
| 7 * |
| 8 * This library is used to observe changes to [Observable] types. It also |
| 9 * has helpers to implement [Observable] objects. |
| 10 * |
| 11 * For example: |
| 12 * |
| 13 * class Monster extends ObservableMixin { |
| 14 * int _health = 100; |
| 15 * static const _HEALTH = 'health'; |
| 16 * get health => _health; |
| 17 * set health(value) { |
| 18 * _health = notifyChange(_HEALTH, _health, value); |
| 19 * } |
| 20 * void damage(int amount) { |
| 21 * print('$this takes $amount damage!'); |
| 22 * health -= amount; |
| 23 * } |
| 24 * toString() => 'Monster'; |
| 25 * |
| 26 * // These methods are temporary until dart2js supports mirrors. |
| 27 * getValue(key) { |
| 28 * if (key == _HEALTH) return health; |
| 29 * return null; |
| 30 * } |
| 31 * setValue(key, val) { |
| 32 * if (key == _HEALTH) health = val; |
| 33 * } |
| 34 * } |
| 35 * |
| 36 * main() { |
| 37 * var obj = new Monster(); |
| 38 * obj.changes.listen((records) { |
| 39 * print('Changes to $obj were: $records'); |
| 40 * }); |
| 41 * // Asynchronously schedules delivery of these changes |
| 42 * obj.damage(10); |
| 43 * obj.damage(20); |
| 44 * print('done!'); |
| 45 * } |
| 46 */ |
| 47 library dart.observe; |
| 48 |
| 49 import 'dart:async'; |
| 50 import 'dart:collection'; |
| 51 import 'dart:math' as math; |
| 52 |
| 53 part 'list_diff.dart'; |
| 54 part 'observe_path.dart'; |
| 55 part 'observable.dart'; |
| 56 part 'observable_box.dart'; |
| 57 part 'observable_list.dart'; |
| 58 part 'observable_map.dart'; |
| OLD | NEW |