-
-
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
enforceActions still allows to modify observers out of action scope #1473
Comments
I am noticing this as well. As suggested by @the-fedorr, this behavior should be guarded even when there are no observers. This will keep it more consistent. |
See https://github.com/mobxjs/mobx/blob/master/CHANGELOG.md#improved-strict-mode for some background of the current behavior |
@the-fedorr @mweststrate |
@linmodev by default mobx won't complain about the lack of actions if the observables are not observed yet. In the next minor, it will also be possible to set |
Released |
I'm running into #338 with the new strict mode enabled. |
Yes, that is totally expected, and one of the reason it was relaxed in the
first place. So, pick your poison :-). Use runInAction or make the thing
that calls the constructor an action.
Op di 17 apr. 2018 om 09:12 schreef Manatsawin Hanmongkolchai <
[email protected]>:
… I'm running into #338 <#338> with
the new strict mode enabled.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1473 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhH9N3gFG3fZRuo73i8CPpSp7cl9mks5tpZXXgaJpZM4TCLWx>
.
|
I suggest to change the available options to: |
In MobX 4.4 / 5.1 the config values have changed to |
When i configure
configure({enforceActions: true});
, i expect that it does what it have to: doesn't allow state modifications outside of actions.But after creation observable (i use, for example,
extendObservable
) i can directly change the observable's values.Digging the code source code, i found that
function checkIfStateModificationsAreAllowed
checks not onlyallowStateChanges
(what is "true" if i'm inside of action), but also detect's the atom's observers length, and if there is no observers - it ignores configurationenforceActions
andallowStateChanges
.In my project it causes that i can modify store whenever i want, until React component is being rendered. After that store is getting an observer (React component) and
checkIfStateModificationsAreAllowed
stops allowing me to modify the store. Looks strange, don't it?I believe what you call "strict" mode should be really strict. Or, at least we could have an option to set "strict-strict" mode.
Also provide the source code i talk about:
The text was updated successfully, but these errors were encountered: