| 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'); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 /** Whether this object is currently observed by listeners or propagators. */ | 53 /** Whether this object is currently observed by listeners or propagators. */ |
| 54 bool get isObserved() { | 54 bool get isObserved() { |
| 55 for (Observable obj = this; obj != null; obj = obj.parent) { | 55 for (Observable obj = this; obj != null; obj = obj.parent) { |
| 56 if (listeners.length > 0) { | 56 if (listeners.length > 0) { |
| 57 return true; | 57 return true; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 AbstractObservable([Observable parent = null]) | 63 AbstractObservable([Observable this.parent = null]) |
| 64 : this.parent = parent, | 64 : uid = EventBatch.genUid(), |
| 65 uid = EventBatch.genUid(), | |
| 66 listeners = new List<ChangeListener>(); | 65 listeners = new List<ChangeListener>(); |
| 67 | 66 |
| 68 bool addChangeListener(ChangeListener listener) { | 67 bool addChangeListener(ChangeListener listener) { |
| 69 if (listeners.indexOf(listener, 0) == -1) { | 68 if (listeners.indexOf(listener, 0) == -1) { |
| 70 listeners.add(listener); | 69 listeners.add(listener); |
| 71 return true; | 70 return true; |
| 72 } | 71 } |
| 73 | 72 |
| 74 return false; | 73 return false; |
| 75 } | 74 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // equality check should be done? | 289 // equality check should be done? |
| 291 if (newValue !== _value) { | 290 if (newValue !== _value) { |
| 292 final oldValue = _value; | 291 final oldValue = _value; |
| 293 _value = newValue; | 292 _value = newValue; |
| 294 recordPropertyUpdate("value", newValue, oldValue); | 293 recordPropertyUpdate("value", newValue, oldValue); |
| 295 } | 294 } |
| 296 } | 295 } |
| 297 | 296 |
| 298 T _value; | 297 T _value; |
| 299 } | 298 } |
| OLD | NEW |