diff --git a/CHANGELOG.md b/CHANGELOG.md index be0a41c..01841b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.28.0 +* add notifyWhenEqual to projectListSplices so equal changes aren't filtered out + ## 0.27.0 * added notifyWhenEqual flag to ObservableMap diff --git a/lib/src/async/differs/list_differ.dart b/lib/src/async/differs/list_differ.dart index 0fae146..daa1d21 100644 --- a/lib/src/async/differs/list_differ.dart +++ b/lib/src/async/differs/list_differ.dart @@ -442,14 +442,14 @@ List> _createInitialSplices( // insert incorrectly, because those items will be shifted. List> projectListSplices( List list, List> records, - [Equality? equality]) { + {Equality? equality, bool notifyWhenEqual = false}) { equality ??= DefaultEquality(); if (records.length <= 1) return records; final splices = >[]; final initialSplices = _createInitialSplices(list, records); for (final splice in initialSplices) { if (splice.addedCount == 1 && splice.removed.length == 1) { - if (splice.removed[0] != list[splice.index]) { + if (notifyWhenEqual || splice.removed[0] != list[splice.index]) { splices.add(splice); } continue; diff --git a/lib/src/async/observable_list.dart b/lib/src/async/observable_list.dart index 593bf30..04db35f 100644 --- a/lib/src/async/observable_list.dart +++ b/lib/src/async/observable_list.dart @@ -297,7 +297,9 @@ class ObservableList extends ListBase bool deliverListChanges() { if (_listRecords == null) return false; - final records = projectListSplices(this, _listRecords!); + //projectListSplices removes equal entries so skip the call when requested + final records = projectListSplices(this, _listRecords!, + notifyWhenEqual: notifyWhenEqual); _listRecords = null; if (hasListObservers && records.isNotEmpty) { diff --git a/pubspec.yaml b/pubspec.yaml index 0027bf8..b843491 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: change_notifier -version: 0.27.0 +version: 0.28.0 description: Support for marking objects as observable homepage: https://github.com/angulardart-community/change_notifier environment: