Chromium Code Reviews| 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:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:collection-dev'; | 8 import 'dart:collection-dev'; |
|
Lasse Reichstein Nielsen
2013/01/29 08:11:22
But collections-dev is imported here, so why shoul
floitsch
2013/01/29 15:41:07
It shouldn't. I will prepare to remove it.
| |
| 9 | 9 |
| 10 part 'ChangeEvent.dart'; | 10 part 'ChangeEvent.dart'; |
| 11 part 'EventBatch.dart'; | 11 part 'EventBatch.dart'; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * An object whose changes are tracked and who can issue events notifying how it | 14 * An object whose changes are tracked and who can issue events notifying how it |
| 15 * has been changed. | 15 * has been changed. |
| 16 */ | 16 */ |
| 17 abstract class Observable { | 17 abstract class Observable { |
| 18 /** Returns a globally unique identifier for the object. */ | 18 /** Returns a globally unique identifier for the object. */ |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 void set length(int value) { | 156 void set length(int value) { |
| 157 _internal.length = value; | 157 _internal.length = value; |
| 158 recordGlobalChange(); | 158 recordGlobalChange(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void clear() { | 161 void clear() { |
| 162 _internal.clear(); | 162 _internal.clear(); |
| 163 recordGlobalChange(); | 163 recordGlobalChange(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 List<T> get reversed => new ReversedListView<T>(this, 0, null); | 166 List<T> get reversed => _internal.reversed; |
|
Lasse Reichstein Nielsen
2013/01/29 08:11:22
That works, but only because you can't assign thro
floitsch
2013/01/29 15:41:07
Should be ok then. If we change that behavior, we
| |
| 167 | 167 |
| 168 void sort([int compare(var a, var b)]) { | 168 void sort([int compare(var a, var b)]) { |
| 169 if (compare == null) compare = Comparable.compare; | 169 if (compare == null) compare = Comparable.compare; |
| 170 _internal.sort(compare); | 170 _internal.sort(compare); |
| 171 recordGlobalChange(); | 171 recordGlobalChange(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void add(T element) { | 174 void add(T element) { |
| 175 recordListInsert(length, element); | 175 recordListInsert(length, element); |
| 176 _internal.add(element); | 176 _internal.add(element); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 throw new UnimplementedError(); | 278 throw new UnimplementedError(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 | 281 |
| 282 // Iterable<T>: | 282 // Iterable<T>: |
| 283 Iterator<T> get iterator => _internal.iterator; | 283 Iterator<T> get iterator => _internal.iterator; |
| 284 | 284 |
| 285 // Collection<T>: | 285 // Collection<T>: |
| 286 Iterable<T> where(bool f(T element)) => _internal.where(f); | 286 Iterable<T> where(bool f(T element)) => _internal.where(f); |
| 287 Iterable mappedBy(f(T element)) => _internal.mappedBy(f); | 287 Iterable mappedBy(f(T element)) => _internal.mappedBy(f); |
| 288 List<T> skip(int count) => _internal.skip(count); | |
| 289 List<T> take(int count) => _internal.take(count); | |
| 288 bool every(bool f(T element)) => _internal.every(f); | 290 bool every(bool f(T element)) => _internal.every(f); |
| 289 bool any(bool f(T element)) => _internal.any(f); | 291 bool any(bool f(T element)) => _internal.any(f); |
| 290 void forEach(void f(T element)) { _internal.forEach(f); } | 292 void forEach(void f(T element)) { _internal.forEach(f); } |
| 291 String join([String separator]) => _internal.join(separator); | 293 String join([String separator]) => _internal.join(separator); |
| 292 T firstMatching(bool test(T value), {T orElse()}) { | 294 T firstMatching(bool test(T value), {T orElse()}) { |
| 293 return _internal.firstMatching(test, orElse: orElse); | 295 return _internal.firstMatching(test, orElse: orElse); |
| 294 } | 296 } |
| 295 T lastMatching(bool test(T value), {T orElse()}) { | 297 T lastMatching(bool test(T value), {T orElse()}) { |
| 296 return _internal.lastMatching(test, orElse: orElse); | 298 return _internal.lastMatching(test, orElse: orElse); |
| 297 } | 299 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 322 // Only fire on an actual change. | 324 // Only fire on an actual change. |
| 323 if (!identical(newValue, _value)) { | 325 if (!identical(newValue, _value)) { |
| 324 final oldValue = _value; | 326 final oldValue = _value; |
| 325 _value = newValue; | 327 _value = newValue; |
| 326 recordPropertyUpdate("value", newValue, oldValue); | 328 recordPropertyUpdate("value", newValue, oldValue); |
| 327 } | 329 } |
| 328 } | 330 } |
| 329 | 331 |
| 330 T _value; | 332 T _value; |
| 331 } | 333 } |
| OLD | NEW |