| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 throw new RangeError.range(start, 0, this.length); | 174 throw new RangeError.range(start, 0, this.length); |
| 175 } | 175 } |
| 176 if (end < start || end > this.length) { | 176 if (end < start || end > this.length) { |
| 177 throw new RangeError.range(end, start, this.length); | 177 throw new RangeError.range(end, start, this.length); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 void _recordChange(ListChangeRecord record) { | 181 void _recordChange(ListChangeRecord record) { |
| 182 if (_listRecords == null) { | 182 if (_listRecords == null) { |
| 183 _listRecords = []; | 183 _listRecords = []; |
| 184 runAsync(deliverChanges); | 184 scheduleMicrotask(deliverChanges); |
| 185 } | 185 } |
| 186 _listRecords.add(record); | 186 _listRecords.add(record); |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool deliverChanges() { | 189 bool deliverChanges() { |
| 190 if (_listRecords == null) return false; | 190 if (_listRecords == null) return false; |
| 191 _summarizeRecords(); | 191 _summarizeRecords(); |
| 192 return super.deliverChanges(); | 192 return super.deliverChanges(); |
| 193 } | 193 } |
| 194 | 194 |
| (...skipping 76 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 |