HI,
I have an issue using the generator syntax inside async actions. When using multiple yield statements inside the action, i get the following runtime error: 'Cannot modify 'Store', the object is protected and can only be modified by using an action'

When using only 1 yield , everything is working fine, but i need the result of the first call in the second call.
it is also working when calling a seperate action to process the received result, but I don't like the separate action....

Is it possible to use this syntax with multiple async calls?
Many thanks!
Are you using flow?
https://github.com/mobxjs/mobx-state-tree/blob/master/docs/async-actions.md#asynchronous-actions-and-middleware
Yes.. I'm using flow
Please provide a small reproduction for this issue, for example by forking the code sandbox linked in the issue template
It seems to be a problem with only one project.
I have created a new project and no exceptions occur when executing 2 yields inside a flow function.
At the moment, we are using the .then() syntax in our project, which is working fine. So if we decide to use flow again, I will have another look at it.
So i guess this issue can be closed.
FWIW, I've been struggling with a similar issue (_Cannot modify 'Store', the object is protected and can only be modified by using an action_ while modifying state within a flow async action) and the problem was that VSCode had auto-imported flow from mobx, not mobx-state-tree...
¯_(ツ)_/¯
Thanks @bourquep, that fixed the problem. Now I only have one issue left.
https://github.com/mobxjs/mobx-state-tree/issues/823
Thanks a lot @bourquep for your tip : encountered exactly this issue while refactoring some code. Could have spent some hours looking without your comment! 👍
FWIW, I've been struggling with a similar issue (_Cannot modify 'Store', the object is protected and can only be modified by using an action_ while modifying state within a
flowasync action) and the problem was that VSCode had auto-importedflowfrommobx, notmobx-state-tree...¯_(ツ)_/¯
Thanks man, you saved my day. :)
@bourquep You saved my life. Thank you.
Conflicting imports from mobx vs mobx-state-tree seems to be a common issue. Any chance some unique alias for the mobx-state-tree version could be added and recommended in documentation / examples?
Conflicting imports from
mobxvsmobx-state-treeseems to be a common issue. Any chance some unique alias for themobx-state-treeversion could be added and recommended in documentation / examples?
I found this the evilest thing in mst. I think the maintainers every time giggles when you use flow from mobx instead flow from mobx-state-tree.
Most helpful comment
FWIW, I've been struggling with a similar issue (_Cannot modify 'Store', the object is protected and can only be modified by using an action_ while modifying state within a
flowasync action) and the problem was that VSCode had auto-importedflowfrommobx, notmobx-state-tree...¯_(ツ)_/¯