Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to bypass observability system for performance; Avoid unnecessary observable notifications of @observable fields of Stores; Fix Reaction lacks toString, so cannot see which reaction causes the error; Add StackTrace to reactions in debug mode to easily spot which reaction it is #844

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
880ee28
add `nonObservableInner`, such that users can bypass observability sy…
fzyzcjy Jul 12, 2022
5a58d06
Merge remote-tracking branch 'origin/master'
fzyzcjy Jul 12, 2022
e1df03a
chore: format code
fzyzcjy Sep 4, 2022
bbd9020
feat: Add `onDispose` callback to `Computed`, such that old values ca…
fzyzcjy Sep 4, 2022
263155b
test: add tests to `disposeValue` #857
fzyzcjy Sep 4, 2022
396cd93
test: add tests for "Allow users to bypass observability system for p…
fzyzcjy Sep 4, 2022
20fe5d3
feat: add `Computed.dispose` #859
fzyzcjy Sep 4, 2022
63d57ef
test: add tests for Computed.dispose
fzyzcjy Sep 4, 2022
ada24f7
test: reproduce #855
fzyzcjy Sep 5, 2022
3b93039
fix: Avoid unnecessary observable notifications of `@observable` fiel…
fzyzcjy Sep 5, 2022
919f203
Merge pull request #4 from mobxjs/master
fzyzcjy Sep 6, 2022
305bd4e
Revert "test: add tests for Computed.dispose"
fzyzcjy Sep 6, 2022
3912572
Revert "feat: add `Computed.dispose` #859"
fzyzcjy Sep 6, 2022
290f8c3
Revert "test: add tests to `disposeValue` #857"
fzyzcjy Sep 6, 2022
424ec02
Revert "feat: Add `onDispose` callback to `Computed`, such that old v…
fzyzcjy Sep 6, 2022
fcc222b
format code and minor change to code
fzyzcjy Sep 6, 2022
637d12b
add Observable.nonObservableValue
fzyzcjy Sep 7, 2022
e852b9b
fix: Reaction lacks toString, so cannot see which reaction causes the…
fzyzcjy Sep 8, 2022
75260bf
feat: Add StackTrace to reactions in debug mode to easily spot which …
fzyzcjy Sep 8, 2022
fecb442
fix linter errors
fzyzcjy Sep 8, 2022
1803928
add toString and debugCreationStack
fzyzcjy Sep 8, 2022
015d35f
Merge branch 'master' into master
amondnet Dec 19, 2022
74ea2e5
Merge branch 'master' into master
amondnet Jan 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add tests for Computed.dispose
fzyzcjy committed Sep 4, 2022
commit 63d57efee52f3464046a1c0917c557387daeed8f
36 changes: 35 additions & 1 deletion mobx/test/computed_test.dart
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ void main() {
});

group(
'when the computation is called twice, should dispose the value generated in the first computation',
'when the computation is called twice, should dispose the unused value',
() {
test('when access Computed twice *outside* reactive environment', () {
expect(computedCallCount, 0);
@@ -339,6 +339,40 @@ void main() {
expect(computedCallCount, 1);
expect(disposeValueArguments, const <String>['A1-Computed#0']);
});

group('when call Computed.dispose()', () {
test('when nobody was observing it, should do nothing', () {
computed.dispose();
expect(computedCallCount, 0);
expect(disposeValueArguments, const <String>[]);
});

test(
'when somebody was observing it, should still dispose the current value',
() {
expect(computedCallCount, 0);
expect(disposeValueArguments, const <String>[]);

late final String computedValue;
final autorunDisposer =
autorun((_) => computedValue = computed.value);
expect(computedValue, 'A1-Computed#0');

expect(computedCallCount, 1);
expect(disposeValueArguments, const <String>[]);

// NOTE this
computed.dispose();

expect(computedCallCount, 1);
expect(disposeValueArguments, const <String>['A1-Computed#0']);

autorunDisposer();

expect(computedCallCount, 1);
expect(disposeValueArguments, const <String>['A1-Computed#0']);
});
});
});
});
}