| 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 library observe.src.list_path_observer; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'package:observe/observe.dart'; |
| 6 | 9 |
| 7 // Inspired by ArrayReduction at: | 10 // Inspired by ArrayReduction at: |
| 8 // https://raw.github.com/rafaelw/ChangeSummary/master/util/array_reduction.js | 11 // https://raw.github.com/rafaelw/ChangeSummary/master/util/array_reduction.js |
| 9 // The main difference is we support anything on the rich Dart Iterable API. | 12 // The main difference is we support anything on the rich Dart Iterable API. |
| 10 | 13 |
| 11 /** | 14 /** |
| 12 * Observes a path starting from each item in the list. | 15 * Observes a path starting from each item in the list. |
| 13 */ | 16 */ |
| 14 class ListPathObserver<E, P> extends ChangeNotifier { | 17 class ListPathObserver<E, P> extends ChangeNotifier { |
| 15 final ObservableList<E> list; | 18 final ObservableList<E> list; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 69 } |
| 67 } else if (lengthAdjust < 0) { | 70 } else if (lengthAdjust < 0) { |
| 68 for (int i = 0; i < -lengthAdjust; i++) { | 71 for (int i = 0; i < -lengthAdjust; i++) { |
| 69 _subs.removeLast().cancel(); | 72 _subs.removeLast().cancel(); |
| 70 } | 73 } |
| 71 int len = _observers.length; | 74 int len = _observers.length; |
| 72 _observers.removeRange(len + lengthAdjust, len); | 75 _observers.removeRange(len + lengthAdjust, len); |
| 73 } | 76 } |
| 74 } | 77 } |
| 75 } | 78 } |
| OLD | NEW |