| 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 observe; | 5 part of 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // list modifications. | 218 // list modifications. |
| 219 // One simple idea: we can simply update the index map as we do the operations | 219 // One simple idea: we can simply update the index map as we do the operations |
| 220 // to the list, then produce the records at the end. | 220 // to the list, then produce the records at the end. |
| 221 void _summarizeRecords() { | 221 void _summarizeRecords() { |
| 222 int oldLength = length; | 222 int oldLength = length; |
| 223 for (var r in _listRecords) { | 223 for (var r in _listRecords) { |
| 224 oldLength += r.removedCount - r.addedCount; | 224 oldLength += r.removedCount - r.addedCount; |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (length != oldLength) { | 227 if (length != oldLength) { |
| 228 notifyPropertyChange(const Symbol('length'), oldLength, length); | 228 notifyPropertyChange(#length, oldLength, length); |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (_listRecords.length == 1) { | 231 if (_listRecords.length == 1) { |
| 232 notifyChange(_listRecords[0]); | 232 notifyChange(_listRecords[0]); |
| 233 _listRecords = null; | 233 _listRecords = null; |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 var items = []; | 237 var items = []; |
| 238 for (int i = 0; i < oldLength; i++) items.add(i); | 238 for (int i = 0; i < oldLength; i++) items.add(i); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 if (added > 0 || removed > 0) { | 272 if (added > 0 || removed > 0) { |
| 273 notifyChange(new ListChangeRecord(startIndex, addedCount: added, | 273 notifyChange(new ListChangeRecord(startIndex, addedCount: added, |
| 274 removedCount: removed)); | 274 removedCount: removed)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 offset += removed - added; | 277 offset += removed - added; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 } | 280 } |
| OLD | NEW |