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
Why do we have to use yield for 'put'-effect? #1669
Comments
Hi there! From my understandings: 1 - Remember that 2 - I'm not really sure if you make parallel work dispatching both actions, but making a |
Thanks for your reply! |
Yup, if you put a list of |
While it's true that put is a dispatch this is slightly more complex. To make various fork+take+put scenarios work we use a simple scheduler under the hood which queues the "nested" puts - that whole queue gets processed within single stack frame, but it means that a single put might not be executed right away.
It is safe to assume that. |
Thanks for the answers! |
you can use yield yield put() |
It's may be the case, whatever action you want to dispatch may have watcher to run some other saga. if you wont place yield before put both generator will run asynchronously and outcome wouldn't be as expected. |
I have two questions of understanding related to the
yield put(someAction)
-syntax (I suppose they are very simple questions, but I couldn't find an exact answer in the documentation).1. Why do we have to
yield
when usingput
?If my understanding is right,
put
-effect will only dispatch an action. Dispatching an action on a redux-store happens fully synchronous. Why do we need to useyield
then? Is it just because every redux-saga effect is built up this way, or am I missing out some async-stuff happening which we need to wait for?2. Is it safe to assume, that the new store is ready after
yield put(...)
?Considering the following syntax:
Is it safe to assume that reducers will always work off
action1
beforeaction2
(in other words:action2
always works with the store previously updated fromaction1
)?Thank you very much for your help.
The text was updated successfully, but these errors were encountered: