| 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 * |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 /** | 64 /** |
| 65 * Notify that the field [name] of this object has been changed. | 65 * Notify that the field [name] of this object has been changed. |
| 66 * | 66 * |
| 67 * The [oldValue] and [newValue] are also recorded. If the two values are | 67 * The [oldValue] and [newValue] are also recorded. If the two values are |
| 68 * identical, no change will be recorded. | 68 * identical, no change will be recorded. |
| 69 * | 69 * |
| 70 * For convenience this returns [newValue]. This makes it easy to use in a | 70 * For convenience this returns [newValue]. This makes it easy to use in a |
| 71 * setter: | 71 * setter: |
| 72 * | 72 * |
| 73 * var _myField; | 73 * var _myField; |
| 74 * get myField => _myField; | 74 * @reflectable get myField => _myField; |
| 75 * set myField(value) { | 75 * @reflectable set myField(value) { |
| 76 * _myField = notifyPropertyChange(#myField, _myField, value); | 76 * _myField = notifyPropertyChange(#myField, _myField, value); |
| 77 * } | 77 * } |
| 78 */ | 78 */ |
| 79 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) | 79 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) |
| 80 => _notifyPropertyChange(this, field, oldValue, newValue); | 80 => _notifyPropertyChange(this, field, oldValue, newValue); |
| 81 | 81 |
| 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 |