| 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, | 73 _recordChange(new ListChangeRecord(index, addedCount: 1, removedCount: 1))
; |
| 74 removedCount: 1)); | |
| 75 } | 74 } |
| 76 _list[index] = value; | 75 _list[index] = value; |
| 77 } | 76 } |
| 78 | 77 |
| 79 // The following methods are here so that we can provide nice change events. | 78 // The following methods are here so that we can provide nice change events. |
| 80 | 79 |
| 81 void setAll(int index, Iterable<E> iterable) { | 80 void setAll(int index, Iterable<E> iterable) { |
| 82 if (iterable is! List && iterable is! Set) { | 81 if (iterable is! List && iterable is! Set) { |
| 83 iterable = iterable.toList(); | 82 iterable = iterable.toList(); |
| 84 } | 83 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 279 } |
| 281 | 280 |
| 282 offset += removed - added; | 281 offset += removed - added; |
| 283 } | 282 } |
| 284 } | 283 } |
| 285 } | 284 } |
| 286 | 285 |
| 287 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base | 286 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base |
| 288 // class and mixins. | 287 // class and mixins. |
| 289 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} | 288 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} |
| OLD | NEW |