-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
New computed decorator does not apply action to setter #3882
Comments
(Implementation note/context - not really an answer) This is a little tricky with the 2023.x decorators spec. Getters and Setters may now have separate decorators applied to them - it's no longer the case that a decorator on one (eg getter) applies to the other (eg setter). The spec has grown enough that MobX may be able to workaround this now (using |
This was a bad idea anyway, so probably better to keep it as is :). |
Then I'd suggest we allow applying public set language(value: string | undefined) {
runInAction(() => {
this.#language = value;
});
} And even if you don't intend to allow |
agreed
Per above, the main guidance is that you make whatever calls this Since you cannot make in JavaScript a field assignment a first class callback of something, there should be a different place where putting |
It seems that with the new decorators, setters for computed getters do not become actions anymore, as it is also mentioned in the documentation:
The code at the bottom works fine with old decorators, but with will report the following error:
Also, it seems there is no way to use like an action decorator on the getter to intentionally make it an action.
How to reproduce the issue:
See also:
mobx/packages/mobx/src/types/computedannotation.ts
Lines 50 to 73 in c22c904
The text was updated successfully, but these errors were encountered: