New computed decorator does not apply action to setter
It seems that with the new decorators, setters for computed getters do not become actions anymore, as it is also mentioned in the documentation:
It is possible to define a setter for computed values as well. Note that these setters cannot be used to alter the value of the computed property directly, but they can be used as an "inverse" of the derivation. Setters are automatically marked as actions
The code at the bottom works fine with old decorators, but with will report the following error:
Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify:
[email protected]
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:
class Store {
@observable
accessor value = 1;
@computed
public get doubleValue() {
return this.value * 2;
}
public set doubleValue(value: number) {
this.value = value / 2;
}
}
const store = new Store();
autorun(() => console.log(store.doubleValue));
store.doubleValue = 32;Source: mobxjs/mobx