-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Recommended way to compose sagas #737
Comments
@Kitanotori
|
Starting from yield takeLatest(...)
yield takeLatest(...) vs yield [
takeLatest(...)
takeLatest(...)
] Not much of a difference. Possibly second might be A LITTLE bit faster, especially if you need to use |
@Andarist If I understand correctly, this advice only applies to yielding helpers from Sagas. What about composing several sagas from different domains? |
In the other thread I've tried to explain (maybe poorly) that the same comment applies somewhat to the part of your question. Helpers and your sagas are not completely different things (only that helpers are a built-in). You want to call both of them with yield fork(saga1)
yield fork(saga2) vs yield [
fork(saga1),
fork(saga2)
] the same comment as above applies. Those are basically the same thing and you can chose whichever you want. The interesting part is what will happen if you yield array of other things. Each of them will get run in parallel and the whole yield will be resolved only once EACH of the things in the array ends. And as you can also yield array of forks (cause... why not?) this makes it only a special case of the parallel effect (which will resolve synchronously as forks are non-blocking). |
By reading the documentation, I couldn't figure out the preferred way to compose sagas. In my reducer files, I have defined watchers in the following way:
My root saga:
Previously I had defined my watchers in separate generator functions using
yield*
, but now it seems to be possible to have them inside the same generator function usingyield
. Is this correct and the recommended approach, and is it possible to simplify things even further?The text was updated successfully, but these errors were encountered: