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 library observe.src.observable; | 5 library observe.src.observable; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 // Note: ObservableProperty is in this list only for the unusual use case of | 10 // Note: ObservableProperty is in this list only for the unusual use case of |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 * [Observable.dirtyCheck] instead. | 181 * [Observable.dirtyCheck] instead. |
182 */ | 182 */ |
183 void notifyChange(ChangeRecord record) { | 183 void notifyChange(ChangeRecord record) { |
184 if (!hasObservers) return; | 184 if (!hasObservers) return; |
185 | 185 |
186 if (_records == null) _records = []; | 186 if (_records == null) _records = []; |
187 _records.add(record); | 187 _records.add(record); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 /** | |
192 * *Deprecated* use [Observable.notifyPropertyChange] instead. | |
193 * | |
194 * This API should not be used as it creates a | |
195 * [PropertyChangeRecord] without oldValue and newValue. | |
196 * | |
197 * Notify the property change. Shorthand for: | |
198 * | |
199 * target.notifyChange(new PropertyChangeRecord(target, name, null, null)); | |
200 */ | |
201 @deprecated | |
202 void notifyProperty(Observable target, Symbol name) { | |
203 target.notifyChange(new PropertyChangeRecord(target, name, null, null)); | |
204 } | |
205 | |
206 // TODO(jmesserly): remove the instance method and make this top-level method | 191 // TODO(jmesserly): remove the instance method and make this top-level method |
207 // public instead? | 192 // public instead? |
208 // NOTE: this is not exported publically. | 193 // NOTE: this is not exported publically. |
209 notifyPropertyChangeHelper(Observable obj, Symbol field, Object oldValue, | 194 notifyPropertyChangeHelper(Observable obj, Symbol field, Object oldValue, |
210 Object newValue) { | 195 Object newValue) { |
211 | 196 |
212 if (obj.hasObservers && oldValue != newValue) { | 197 if (obj.hasObservers && oldValue != newValue) { |
213 obj.notifyChange(new PropertyChangeRecord(obj, field, oldValue, newValue)); | 198 obj.notifyChange(new PropertyChangeRecord(obj, field, oldValue, newValue)); |
214 } | 199 } |
215 return newValue; | 200 return newValue; |
216 } | 201 } |
217 | 202 |
218 // NOTE: this is not exported publically. | 203 // NOTE: this is not exported publically. |
219 final objectType = reflectClass(Object); | 204 final objectType = reflectClass(Object); |
OLD | NEW |