-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Cannot set observable.value #788
Comments
By default, MobX enforces a rule that all mutations to observables should happen inside an action. This is part of the configuration for a ReactiveContext. If you mutate an observable that is being observed, outside of an action, MobX will throw an Exception. This is a safety measure to ensure there are no stray mutations happening in your application. Do not mutate observables outside an action. Although not advisable, you can relax this restriction by setting a different config for the ReactiveContext. docs: https://mobx.netlify.app/api/action/#safety-first void testIt() {
final greetings = Observable('Hello');
final dispose = autorun((_) {
print(greetings.value);
});
runInAction((){
greetings.value = 'World';
});
dispose();
} |
Thank you @amondnet , much appreciated My issue is that the code I pasted is mentioned in the documentations, in the Core Concepts section, and shown as being valid code. Please see the attached screenshot: I believe we need to update the documentations. Thoughts? |
Absolutely...would love a PR from you @vandadnp if you can :-) |
Sure, I'll take a look 💙 |
Hi and thank you for MobX, it's amazing, I appreciate the hard work.
Given the following code:
I am getting the following error in Flutter:
It seems like we are not allowed to set the value of an observable like that anymore but the examples all show the code above as being valid.
The text was updated successfully, but these errors were encountered: