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

feat: Adds custom equals for creating observables. #907

Merged
merged 3 commits into from
May 5, 2023

Conversation

amondnet
Copy link
Collaborator

@amondnet amondnet commented Mar 15, 2023

Allows a reaction to be fired even if the value hasn't changed.
Adds custom equals for creating observables.

#844
fix #903


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, organized by version
  • Run the melo run set_version command from the root directory
  • Include the necessary reviewers for the PR
  • Update the docs if there are any API changes or additions to functionality

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #907 (c33a443) into master (ea1ba4f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #907   +/-   ##
=======================================
  Coverage   98.98%   98.99%           
=======================================
  Files          56       56           
  Lines        1980     1987    +7     
=======================================
+ Hits         1960     1967    +7     
  Misses         20       20           
Flag Coverage Δ
flutter_mobx 100.00% <ø> (ø)
mobx 98.55% <100.00%> (+<0.01%) ⬆️
mobx_codegen 100.00% <100.00%> (ø)

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

Impacted Files Coverage Δ
mobx/lib/src/core.dart 100.00% <ø> (ø)
mobx/lib/src/api/annotations.dart 80.00% <100.00%> (+5.00%) ⬆️
mobx/lib/src/core/atom_extensions.dart 100.00% <100.00%> (ø)
mobx_codegen/lib/src/store_class_visitor.dart 100.00% <100.00%> (ø)
mobx_codegen/lib/src/template/observable.dart 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

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

@amondnet amondnet linked an issue Mar 15, 2023 that may be closed by this pull request
@amondnet amondnet self-assigned this Mar 16, 2023
@amondnet amondnet changed the title feat: always notify observable feat: Adds custom equals for creating observables. Apr 12, 2023
@gabrielaraujoz
Copy link

Hey there @pavanpodila & @fzyzcjy is there any way of knowing when this pr will be reviewed/released? thanks a lot!

Copy link
Collaborator

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

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

LGTM! Btw, I love https://pub.dev/packages/json_serializable's approach when it comes to defining a custom function. For example,

@JsonKey(fromJson: myMethod)
whatever_thing

Sth myMethod(Sth sth) { ... }

Then no need to provide a string

@Gaurav-CareMonitor
Copy link

Any updates on this?

@amondnet
Copy link
Collaborator Author

amondnet commented May 4, 2023

@fzyzcjy Yeah, I like the approach of json_serializable too. I've modified it as shown below.

bool customEquals(String? oldValue, String? newValue) => oldValue != newValue;

abstract class _TestStore with Store {
  _TestStore();

  @MakeObservable(equals: customEquals)
  String custom = 'stuff';

  @alwaysNotify
  String always = 'stuff';
}

@amondnet amondnet requested a review from fzyzcjy May 4, 2023 03:58
@amondnet amondnet merged commit 6e6378c into mobxjs:master May 5, 2023
@amondnet amondnet deleted the always-notify-observable branch May 5, 2023 15:35
@amondnet
Copy link
Collaborator Author

@all-contributors please add @fzyzcjy for review

@allcontributors
Copy link
Contributor

@amondnet

I've put up a pull request to add @fzyzcjy! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Map Observables not working in v2.1.4
4 participants