Skip to content

Commit

Permalink
Avoid unnecessary observable notifications of Iterable or Map fields
Browse files Browse the repository at this point in the history
  • Loading branch information
amondnet committed Nov 2, 2023
1 parent e0fb33d commit 9489352
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mobx/test/atom_extensions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ void main() {
() {
final store = _ExampleStore();

final autorunResults = <String>[];
autorun((_) => autorunResults.add(store.value3));
final autorunResults = <int>[];
autorun((_) => autorunResults.add(store.value3.length));

expect(autorunResults, ['first']); // length: 5
expect(autorunResults, [5]); // length: 5

// length: 5, should not trigger
store.value3 = 'third';

expect(autorunResults, ['first']);
expect(autorunResults, [5]);

// length: 6, should trigger
store.value3 = 'second';

expect(autorunResults, ['first', 'second']);
expect(autorunResults, [5, 6]);
});

test(
Expand Down Expand Up @@ -120,7 +120,7 @@ void main() {

class _ExampleStore = __ExampleStore with _$_ExampleStore;

bool _equals(String? oldValue, String? newValue) => (oldValue == newValue);
bool _equals(String? oldValue, String? newValue) => (oldValue?.length == newValue?.length);

abstract class __ExampleStore with Store {
@observable
Expand Down

0 comments on commit 9489352

Please sign in to comment.