async/await and runInAction #2645
Answered
by
MariiaIasakova
MariiaIasakova
asked this question in
Q&A
-
Like documentation said, I need to wrap all state changes in runInAction after await. Is the next code right?
|
Beta Was this translation helpful? Give feedback.
Answered by
MariiaIasakova
Nov 25, 2020
Replies: 3 comments 4 replies
-
Can you ask some concrete questions? Does the code work for you? |
Beta Was this translation helpful? Give feedback.
0 replies
-
code works for me
in some cases like this
I want to know your recommendation how to structure it right |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
danielkcz
-
Please check the docs on actions > async actions.
…On Thu, 8 Apr 2021, 23:56 Kiryl Chetyrbak, ***@***.***> wrote:
@mweststrate <https://github.com/mweststrate> hi. can observable be
updated straight from await or it has to be wrapped into runInAction?
something like this:
@action
foo = async () => {
myObservable = await fetchData();
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2645 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBGMV74MEZED5EK6K4DTHYYC3ANCNFSM4UCNQIYQ>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code works for me
also it works in this
in some cases like this