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 part of mdv_observe; | 5 part of mdv_observe; |
6 | 6 |
7 /** | 7 /** |
8 * Represents an observable list of model values. If any items are added, | 8 * Represents an observable list of model values. If any items are added, |
9 * removed, or replaced, then observers that are listening to [changes] | 9 * removed, or replaced, then observers that are listening to [changes] |
10 * will be notified. | 10 * will be notified. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 _list.length = value; | 65 _list.length = value; |
66 } | 66 } |
67 | 67 |
68 E operator [](int index) => _list[index]; | 68 E operator [](int index) => _list[index]; |
69 | 69 |
70 void operator []=(int index, E value) { | 70 void operator []=(int index, E value) { |
71 var oldValue = _list[index]; | 71 var oldValue = _list[index]; |
72 if (hasObservers) { | 72 if (hasObservers) { |
73 _recordChange(new ListChangeRecord(index, addedCount: 1, removedCount: 1))
; | 73 _recordChange(new ListChangeRecord(index, addedCount: 1, |
| 74 removedCount: 1)); |
74 } | 75 } |
75 _list[index] = value; | 76 _list[index] = value; |
76 } | 77 } |
77 | 78 |
78 // The following methods are here so that we can provide nice change events. | 79 // The following methods are here so that we can provide nice change events. |
79 | 80 |
80 void setAll(int index, Iterable<E> iterable) { | 81 void setAll(int index, Iterable<E> iterable) { |
81 if (iterable is! List && iterable is! Set) { | 82 if (iterable is! List && iterable is! Set) { |
82 iterable = iterable.toList(); | 83 iterable = iterable.toList(); |
83 } | 84 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 280 } |
280 | 281 |
281 offset += removed - added; | 282 offset += removed - added; |
282 } | 283 } |
283 } | 284 } |
284 } | 285 } |
285 | 286 |
286 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base | 287 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base |
287 // class and mixins. | 288 // class and mixins. |
288 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} | 289 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} |
OLD | NEW |