| 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 part of observe; | 5 part of observe; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Base class implementing [Observable] object that performs its own change | 8 * Base class implementing [Observable] object that performs its own change |
| 9 * notifications, and does not need to be considered by [Observable.dirtyCheck]. | 9 * notifications, and does not need to be considered by [Observable.dirtyCheck]. |
| 10 * | 10 * |
| 11 * When a field, property, or indexable item is changed, a derived class should | 11 * When a field, property, or indexable item is changed, a derived class should |
| 12 * call [notifyPropertyChange]. See that method for an example. | 12 * call [notifyPropertyChange]. See that method for an example. |
| 13 */ | 13 */ |
| 14 typedef ChangeNotifierBase = Object with ChangeNotifierMixin; | 14 class ChangeNotifierBase = Object with ChangeNotifierMixin; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Mixin implementing [Observable] object that performs its own change | 17 * Mixin implementing [Observable] object that performs its own change |
| 18 * notifications, and does not need to be considered by [Observable.dirtyCheck]. | 18 * notifications, and does not need to be considered by [Observable.dirtyCheck]. |
| 19 * | 19 * |
| 20 * When a field, property, or indexable item is changed, a derived class should | 20 * When a field, property, or indexable item is changed, a derived class should |
| 21 * call [notifyPropertyChange]. See that method for an example. | 21 * call [notifyPropertyChange]. See that method for an example. |
| 22 */ | 22 */ |
| 23 abstract class ChangeNotifierMixin implements Observable { | 23 abstract class ChangeNotifierMixin implements Observable { |
| 24 StreamController _changes; | 24 StreamController _changes; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void notifyChange(ChangeRecord record) { | 82 void notifyChange(ChangeRecord record) { |
| 83 if (!hasObservers) return; | 83 if (!hasObservers) return; |
| 84 | 84 |
| 85 if (_records == null) { | 85 if (_records == null) { |
| 86 _records = []; | 86 _records = []; |
| 87 scheduleMicrotask(deliverChanges); | 87 scheduleMicrotask(deliverChanges); |
| 88 } | 88 } |
| 89 _records.add(record); | 89 _records.add(record); |
| 90 } | 90 } |
| 91 } | 91 } |
| OLD | NEW |