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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 List getRange(int start, int length) { | 257 List getRange(int start, int length) { |
258 throw const NotImplementedException(); | 258 throw const NotImplementedException(); |
259 } | 259 } |
260 | 260 |
261 // Iterable<T>: | 261 // Iterable<T>: |
262 Iterator<T> iterator() => _internal.iterator(); | 262 Iterator<T> iterator() => _internal.iterator(); |
263 | 263 |
264 // Collection<T>: | 264 // Collection<T>: |
265 Collection<T> filter(bool f(T element)) => _internal.filter(f); | 265 Collection<T> filter(bool f(T element)) => _internal.filter(f); |
| 266 Collection map(f(T element)) => _internal.map(f); |
266 bool every(bool f(T element)) => _internal.every(f); | 267 bool every(bool f(T element)) => _internal.every(f); |
267 bool some(bool f(T element)) => _internal.some(f); | 268 bool some(bool f(T element)) => _internal.some(f); |
268 void forEach(void f(T element)) { _internal.forEach(f); } | 269 void forEach(void f(T element)) { _internal.forEach(f); } |
269 bool isEmpty() => length == 0; | 270 bool isEmpty() => length == 0; |
270 } | 271 } |
271 | 272 |
272 // TODO(jmesserly): is this too granular? Other similar systems make whole | 273 // TODO(jmesserly): is this too granular? Other similar systems make whole |
273 // classes observable instead of individual fields. The memory cost of having | 274 // classes observable instead of individual fields. The memory cost of having |
274 // every field effectively boxed, plus having a listeners list is likely too | 275 // every field effectively boxed, plus having a listeners list is likely too |
275 // much. Also, making a value observable necessitates adding ".value" to lots | 276 // much. Also, making a value observable necessitates adding ".value" to lots |
(...skipping 13 matching lines...) Expand all Loading... |
289 // equality check should be done? | 290 // equality check should be done? |
290 if (newValue !== _value) { | 291 if (newValue !== _value) { |
291 final oldValue = _value; | 292 final oldValue = _value; |
292 _value = newValue; | 293 _value = newValue; |
293 recordPropertyUpdate("value", newValue, oldValue); | 294 recordPropertyUpdate("value", newValue, oldValue); |
294 } | 295 } |
295 } | 296 } |
296 | 297 |
297 T _value; | 298 T _value; |
298 } | 299 } |
OLD | NEW |