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

fix: Allow action field decorators without makeObservable (#3879) #3902

Merged
merged 7 commits into from
Sep 16, 2024

Conversation

jzhan-canva
Copy link
Contributor

@jzhan-canva jzhan-canva commented Jul 10, 2024

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (yarn mobx test:performance)

Similar to #3883 (credit to @Obi-Dann ) but add extra handling for @action.bound on field, for example

class A {
  @action.bound
  doSomething = function() {...} // `this` should be bound to instance of class A
}

fix #3879

Copy link

changeset-bot bot commented Jul 10, 2024

🦋 Changeset detected

Latest commit: b6b84df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

* For Babel make sure the plugin [`proposal-decorators`](https://babeljs.io/docs/babel-plugin-proposal-decorators) is enabled with the highest version (currently `2023-05`). [Example commit](https://github.com/mweststrate/currencies-demo/commit/4999d2228208f3e1e10bc00a272046eaefde8585).

- TypeScript (5.0 and higher, make sure that the `experimentalDecorators` flag is NOT enabled). [Example commit](https://github.com/mweststrate/currencies-demo/commit/acb9ac8c148e8beef88042c847bb395131e85d60).
- For Babel make sure the plugin [`proposal-decorators`](https://babeljs.io/docs/babel-plugin-proposal-decorators) is enabled with the highest version (currently `2023-05`). [Example commit](https://github.com/mweststrate/currencies-demo/commit/4999d2228208f3e1e10bc00a272046eaefde8585).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just auto-formatting

@jzhan-canva
Copy link
Contributor Author

Hi @Matchlighter I updated doc to explain the difference behaviour between legacy and modern
also added a new unit test to demonstrate the difference

@Matchlighter Matchlighter merged commit a1cf2c6 into mobxjs:main Sep 16, 2024
1 check passed
This was referenced Sep 16, 2024
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.

@action decorators on fields do not convert the field value into action
2 participants