| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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('observable'); | 5 #library('observable'); |
| 6 | 6 |
| 7 #import('dart:coreimpl'); | 7 #import('dart:coreimpl'); |
| 8 | 8 |
| 9 #source('ChangeEvent.dart'); | 9 #source('ChangeEvent.dart'); |
| 10 #source('EventBatch.dart'); | 10 #source('EventBatch.dart'); |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * An object whose changes are tracked and who can issue events notifying how it | 13 * An object whose changes are tracked and who can issue events notifying how it |
| 14 * has been changed. | 14 * has been changed. |
| 15 */ | 15 */ |
| 16 interface Observable { | 16 abstract class Observable { |
| 17 /** Returns a globally unique identifier for the object. */ | 17 /** Returns a globally unique identifier for the object. */ |
| 18 // TODO(sigmund): remove once dart supports maps with arbitrary keys. | 18 // TODO(sigmund): remove once dart supports maps with arbitrary keys. |
| 19 final int uid; | 19 int get uid; |
| 20 | 20 |
| 21 /** Listeners on this model. */ | 21 /** Listeners on this model. */ |
| 22 final List<ChangeListener> listeners; | 22 List<ChangeListener> get listeners; |
| 23 | 23 |
| 24 /** The parent observable to notify when this child is changed. */ | 24 /** The parent observable to notify when this child is changed. */ |
| 25 final Observable parent; | 25 Observable get parent; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Adds a listener for changes on this observable instance. Returns whether | 28 * Adds a listener for changes on this observable instance. Returns whether |
| 29 * the listener was added successfully. | 29 * the listener was added successfully. |
| 30 */ | 30 */ |
| 31 bool addChangeListener(ChangeListener listener); | 31 bool addChangeListener(ChangeListener listener); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Removes a listener for changes on this observable instance. Returns whether | 34 * Removes a listener for changes on this observable instance. Returns whether |
| 35 * the listener was removed successfully. | 35 * the listener was removed successfully. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // equality check should be done? | 290 // equality check should be done? |
| 291 if (newValue !== _value) { | 291 if (newValue !== _value) { |
| 292 final oldValue = _value; | 292 final oldValue = _value; |
| 293 _value = newValue; | 293 _value = newValue; |
| 294 recordPropertyUpdate("value", newValue, oldValue); | 294 recordPropertyUpdate("value", newValue, oldValue); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 T _value; | 298 T _value; |
| 299 } | 299 } |
| OLD | NEW |