From 515161cdfbb5e9d4bed9e0377e593cc9f1e9cc3d Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:06:37 -0600 Subject: [PATCH 1/6] don't call projectListSplices when notifyWhenEqual is set --- lib/src/async/observable_list.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/async/observable_list.dart b/lib/src/async/observable_list.dart index 593bf30..a9b5943 100644 --- a/lib/src/async/observable_list.dart +++ b/lib/src/async/observable_list.dart @@ -297,7 +297,13 @@ 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 = notifyWhenEqual + ? _listRecords! + : projectListSplices( + this, + _listRecords!, + ); _listRecords = null; if (hasListObservers && records.isNotEmpty) { From 9cea934844ce1fdab2809517d59225a44765df92 Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:13:30 -0600 Subject: [PATCH 2/6] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be0a41c..70f15b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.28.0 +* skip projectListSplices when notifyWhenEqual is set + ## 0.27.0 * added notifyWhenEqual flag to ObservableMap From 6874168174fb50e73e343d034090024fad28acf2 Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:13:52 -0600 Subject: [PATCH 3/6] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From f3a4f4587d1c9b9180e93351db66dfa139555486 Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:06:17 -0600 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f15b3..01841b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## 0.28.0 -* skip projectListSplices when notifyWhenEqual is set +* add notifyWhenEqual to projectListSplices so equal changes aren't filtered out ## 0.27.0 * added notifyWhenEqual flag to ObservableMap From 6e672de680cfca940704b8f8e0844a87a69e081b Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:07:26 -0600 Subject: [PATCH 5/6] Update observable_list.dart --- lib/src/async/observable_list.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/async/observable_list.dart b/lib/src/async/observable_list.dart index a9b5943..04db35f 100644 --- a/lib/src/async/observable_list.dart +++ b/lib/src/async/observable_list.dart @@ -298,12 +298,8 @@ class ObservableList extends ListBase bool deliverListChanges() { if (_listRecords == null) return false; //projectListSplices removes equal entries so skip the call when requested - final records = notifyWhenEqual - ? _listRecords! - : projectListSplices( - this, - _listRecords!, - ); + final records = projectListSplices(this, _listRecords!, + notifyWhenEqual: notifyWhenEqual); _listRecords = null; if (hasListObservers && records.isNotEmpty) { From 682bcea22a99dcb547f8171c9da9c637f8d7a885 Mon Sep 17 00:00:00 2001 From: tylandercasper <5085108+tylandercasper@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:09:11 -0600 Subject: [PATCH 6/6] Update list_differ.dart --- lib/src/async/differs/list_differ.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;