Chromium Code Reviews| Index: lib/src/observable_list.dart |
| diff --git a/lib/src/observable_list.dart b/lib/src/observable_list.dart |
| index 9d09b38d560b43844f98b40f7d2ea2ff44a28cdd..ae76717e17edb6984d93d969c2b9cdf155235aa0 100644 |
| --- a/lib/src/observable_list.dart |
| +++ b/lib/src/observable_list.dart |
| @@ -15,7 +15,7 @@ import 'list_diff.dart' show projectListSplices, calcSplices; |
| class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| List<ListChangeRecord> _listRecords; |
| - StreamController _listChanges; |
| + StreamController<List<ListChangeRecord>> _listChanges; |
| /// The inner [List<E>] with the actual storage. |
| final List<E> _list; |
| @@ -58,14 +58,14 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| Stream<List<ListChangeRecord>> get listChanges { |
| if (_listChanges == null) { |
| // TODO(jmesserly): split observed/unobserved notions? |
| - _listChanges = new StreamController.broadcast(sync: true, |
| - onCancel: () { _listChanges = null; }); |
| + _listChanges = new StreamController.broadcast(sync: true, onCancel: () { |
| + _listChanges = null; |
| + }); |
| } |
| return _listChanges.stream; |
| } |
| - bool get hasListObservers => |
| - _listChanges != null && _listChanges.hasListener; |
| + bool get hasListObservers => _listChanges != null && _listChanges.hasListener; |
| @reflectable int get length => _list.length; |
| @@ -92,8 +92,8 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| @reflectable void operator []=(int index, E value) { |
| var oldValue = _list[index]; |
| if (hasListObservers && oldValue != value) { |
| - _recordChange(new ListChangeRecord(this, index, addedCount: 1, |
| - removed: [oldValue])); |
| + _recordChange(new ListChangeRecord(this, index, |
| + addedCount: 1, removed: [oldValue])); |
| } |
| _list[index] = value; |
| } |
| @@ -115,8 +115,8 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| } |
| var len = iterable.length; |
|
Bob Nystrom
2016/01/22 18:50:25
Nit: "len" -> "length"
since you're in here anywa
vsm
2016/01/22 19:05:05
Done.
|
| if (hasListObservers && len > 0) { |
| - _recordChange(new ListChangeRecord(this, index, addedCount: len, |
| - removed: _list.getRange(index, len).toList())); |
| + _recordChange(new ListChangeRecord(this, index, |
| + addedCount: len, removed: _list.getRange(index, len).toList())); |
|
Bob Nystrom
2016/01/22 18:50:25
"getRange(index, len).toList()" -> "sublist(index,
vsm
2016/01/22 19:05:05
Done.
|
| } |
| _list.setAll(index, iterable); |
| } |
| @@ -188,8 +188,8 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| _notifyChangeLength(len, _list.length); |
| if (hasListObservers && insertionLength > 0) { |
| - _recordChange(new ListChangeRecord(this, index, |
| - addedCount: insertionLength)); |
| + _recordChange( |
| + new ListChangeRecord(this, index, addedCount: insertionLength)); |
| } |
| } |
| @@ -215,7 +215,6 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| _list[index] = element; |
| } |
| - |
| E removeAt(int index) { |
| E result = this[index]; |
| removeRange(index, index + 1); |
| @@ -281,14 +280,13 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier { |
| /// Complexity is `O(l * p)` where `l` is the length of the current list and |
| /// `p` is the length of the old list. |
| static List<ListChangeRecord> calculateChangeRecords( |
| - List<Object> oldValue, List<Object> newValue) => |
| + List<Object> oldValue, List<Object> newValue) => |
| calcSplices(newValue, 0, newValue.length, oldValue, 0, oldValue.length); |
| /// Updates the [previous] list using the change [records]. For added items, |
| /// the [current] list is used to find the current value. |
| static void applyChangeRecords(List<Object> previous, List<Object> current, |
| List<ListChangeRecord> changeRecords) { |
| - |
| if (identical(previous, current)) { |
| throw new ArgumentError("can't use same list for previous and current"); |
| } |