| 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 * Interface representing an observable object. This is used by data in | 8 * Interface representing an observable object. This is used by data in |
| 9 * model-view architectures to notify interested parties of [changes]. | 9 * model-view architectures to notify interested parties of [changes]. |
| 10 * | 10 * |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 */ | 70 */ |
| 71 static void dirtyCheck() => dirtyCheckObservables(); | 71 static void dirtyCheck() => dirtyCheckObservables(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Base class implementing [Observable]. | 75 * Base class implementing [Observable]. |
| 76 * | 76 * |
| 77 * When a field, property, or indexable item is changed, the change record | 77 * When a field, property, or indexable item is changed, the change record |
| 78 * will be sent to [changes]. | 78 * will be sent to [changes]. |
| 79 */ | 79 */ |
| 80 typedef ObservableBase = Object with ObservableMixin; | 80 class ObservableBase = Object with ObservableMixin; |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Mixin for implementing [Observable] objects. | 83 * Mixin for implementing [Observable] objects. |
| 84 * | 84 * |
| 85 * When a field, property, or indexable item is changed, the change record | 85 * When a field, property, or indexable item is changed, the change record |
| 86 * will be sent to [changes]. | 86 * will be sent to [changes]. |
| 87 */ | 87 */ |
| 88 abstract class ObservableMixin implements Observable { | 88 abstract class ObservableMixin implements Observable { |
| 89 StreamController _changes; | 89 StreamController _changes; |
| 90 InstanceMirror _mirror; | 90 InstanceMirror _mirror; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue, | 205 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue, |
| 206 Object newValue) { | 206 Object newValue) { |
| 207 | 207 |
| 208 // TODO(jmesserly): should this be == instead of identical, to prevent | 208 // TODO(jmesserly): should this be == instead of identical, to prevent |
| 209 // spurious loops? | 209 // spurious loops? |
| 210 if (obj.hasObservers && !identical(oldValue, newValue)) { | 210 if (obj.hasObservers && !identical(oldValue, newValue)) { |
| 211 obj.notifyChange(new PropertyChangeRecord(field)); | 211 obj.notifyChange(new PropertyChangeRecord(field)); |
| 212 } | 212 } |
| 213 return newValue; | 213 return newValue; |
| 214 } | 214 } |
| OLD | NEW |