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

Conversation

fzyzcjy
Copy link
Collaborator

@fzyzcjy fzyzcjy commented Jul 12, 2022

Close #857
Close #858
Close #859
Close #855
Close #864

Pull Request Checklist

  • If the changes are being made to code, ensure the version in pubspec.yaml is updated.
  • Increment the major/minor/patch/patch-count, depending on the complexity of change
  • Add the necessary unit tests to ensure the coverage does not drop
  • Update the Changelog to include all changes made in this PR
  • Run the set:versions command using npm or yarn. You can find this command in the package.json file in the root directory
  • Include the necessary reviewers for the PR
  • Update the docs if there are any API changes or additions to functionality

@netlify
Copy link

netlify bot commented Jul 12, 2022

Deploy Preview for mobx canceled.

Name Link
🔨 Latest commit 1803928
🔍 Latest deploy log https://app.netlify.com/sites/mobx/deploys/6319c5e7db1fa0000e17006a

@fzyzcjy
Copy link
Collaborator Author

fzyzcjy commented Jul 12, 2022

p.s. I may not merge this before PRs like #842 is merged, since otherwise my master branch will be destoryed

@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #844 (74ea2e5) into master (13b7e6d) will decrease coverage by 0.15%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #844      +/-   ##
==========================================
- Coverage   98.96%   98.81%   -0.15%     
==========================================
  Files          55       55              
  Lines        1924     1945      +21     
==========================================
+ Hits         1904     1922      +18     
- Misses         20       23       +3     
Flag Coverage Δ
flutter_mobx 100.00% <ø> (ø)
mobx 98.33% <86.36%> (-0.20%) ⬇️
mobx_codegen 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mobx/lib/src/core/atom.dart 93.87% <0.00%> (-6.13%) ⬇️
...rc/api/observable_collections/observable_list.dart 100.00% <100.00%> (ø)
...src/api/observable_collections/observable_map.dart 100.00% <100.00%> (ø)
...src/api/observable_collections/observable_set.dart 100.00% <100.00%> (ø)
mobx/lib/src/core/action.dart 100.00% <100.00%> (ø)
mobx/lib/src/core/atom_extensions.dart 100.00% <100.00%> (ø)
mobx/lib/src/core/computed.dart 100.00% <100.00%> (ø)
mobx/lib/src/core/context.dart 97.18% <100.00%> (+0.01%) ⬆️
mobx/lib/src/core/observable.dart 100.00% <100.00%> (ø)
mobx/lib/src/core/reaction.dart 98.57% <100.00%> (+0.04%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13b7e6d...74ea2e5. Read the comment docs.

@fzyzcjy fzyzcjy requested a review from amondnet July 30, 2022 08:46
Copy link
Collaborator

@amondnet amondnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please add a changelog and version bump for the mobx package.
  2. Need some more unit tests in places where Codecov has flagged.
    test('bypass observable system', () {
      final list = ObservableList<int>();
      var count = -1;

      expect(list.nonObservableInner.length, 0);

      final d = autorun((_) {
        count = list.nonObservableInner.length;
      });

      expect(count, equals(0));

      list.add(20);
      expect(count, equals(0));
      d();
    });

@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance Allow users to bypass observability system for performance; Add onDispose callback to Computed, such that old values can be properly disposed Sep 4, 2022
@fzyzcjy
Copy link
Collaborator Author

fzyzcjy commented Sep 4, 2022

Add onDispose callback to Computed, such that old values can be properly disposed

feature implemented, test added, and passed

@fzyzcjy
Copy link
Collaborator Author

fzyzcjy commented Sep 4, 2022

@amondnet tests added

@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Add onDispose callback to Computed, such that old values can be properly disposed Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed Sep 4, 2022
@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed; Add Computed.dispose() method, which disposes existing cached value Sep 4, 2022
@amondnet amondnet self-requested a review September 5, 2022 02:28
@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed; Add Computed.dispose() method, which disposes existing cached value Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed; Add Computed.dispose() method, which disposes existing cached value; Avoid unnecessary observable notifications of @observable fields of Stores; Will PR if it is not a deliberate feature Sep 5, 2022
@fzyzcjy
Copy link
Collaborator Author

fzyzcjy commented Sep 5, 2022

test reproduced #855

image

@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Add disposeValue callback to Computed, such that old values can be properly disposed; Add Computed.dispose() method, which disposes existing cached value; Avoid unnecessary observable notifications of @observable fields of Stores; Will PR if it is not a deliberate feature Allow users to bypass observability system for performance; Avoid unnecessary observable notifications of @observable fields of Stores; Will PR if it is not a deliberate feature Sep 6, 2022
@fzyzcjy
Copy link
Collaborator Author

fzyzcjy commented Sep 6, 2022

Revert "dispose"-related features according to #860

This reverts commit 263155b.

# Conflicts:
#	mobx/test/computed_test.dart
…alues can be properly disposed mobxjs#857"

This reverts commit bbd9020.
@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Avoid unnecessary observable notifications of @observable fields of Stores; Will PR if it is not a deliberate feature Allow users to bypass observability system for performance; Avoid unnecessary observable notifications of @observable fields of Stores Sep 6, 2022
@fzyzcjy fzyzcjy changed the title Allow users to bypass observability system for performance; Avoid unnecessary observable notifications of @observable fields of Stores 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 Sep 8, 2022
@fzyzcjy fzyzcjy changed the title 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 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 Sep 8, 2022
Copy link
Collaborator

@amondnet amondnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ghenry
Copy link

ghenry commented Dec 19, 2022

Hi all,

If this is in a "LGTM" state, is it just awaiting for @pavanpodila to approve or can someone else help with the load?

Thanks.

@amondnet
Copy link
Collaborator

@fzyzcjy @ghenry
This PR has solved many issues( #857, #858, #859, #855, #864). If you bump the version and write a chagelog, I'll merge it.

@amondnet amondnet mentioned this pull request Jan 27, 2023
7 tasks
@amondnet
Copy link
Collaborator

Hi, @fzyzcjy
I add the missing tests, bump the version and write the changelog. #894

@amondnet amondnet closed this Jan 30, 2023
amondnet added a commit to amondnet/mobx.dart that referenced this pull request Feb 14, 2023
amondnet added a commit that referenced this pull request Feb 16, 2023
* add `nonObservableInner`, such that users can bypass observability system for performance

* chore: format code

* feat: Add `onDispose` callback to `Computed`, such that old values can be properly disposed #857

* test: add tests to `disposeValue` #857

* test: add tests for "Allow users to bypass observability system for performance"

* feat: add `Computed.dispose` #859

* test: add tests for Computed.dispose

* test: reproduce #855

* fix: Avoid unnecessary observable notifications of `@observable` fields of `Store`s #855

* Revert "test: add tests for Computed.dispose"

This reverts commit 63d57ef.

* Revert "feat: add `Computed.dispose` #859"

This reverts commit 20fe5d3.

* Revert "test: add tests to `disposeValue` #857"

This reverts commit 263155b.

# Conflicts:
#	mobx/test/computed_test.dart

* Revert "feat: Add `onDispose` callback to `Computed`, such that old values can be properly disposed #857"

This reverts commit bbd9020.

* format code and minor change to code

* add Observable.nonObservableValue

* fix: Reaction lacks toString, so cannot see which reaction causes the error #864

* feat: Add StackTrace to reactions in debug mode to easily spot which reaction it is #864

* fix linter errors

* add toString and debugCreationStack

* test: add atom_test

---------

Co-authored-by: fzyzcjy <ch271828n@outlook.com>
Co-authored-by: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment