question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question/clarification] Starting root sagas

See original GitHub issue

I’m just trying to figure out how to start a root saga the correct way.

In your beginner tutorial (http://yelouafi.github.io/redux-saga/docs/introduction/BeginnerTutorial.html) you start the root saga this way:

// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield [
    helloSaga(),
    watchIncrementAsync()
  ]
}

But in the most examples (like https://github.com/yelouafi/redux-saga/blob/master/examples/shopping-cart/src/sagas/index.js) you start it this way:

export default function* root() {
  yield [
    fork(getAllProducts),
    fork(watchGetProducts),
    fork(watchCheckout)
  ]
}

See also https://github.com/yelouafi/redux-saga/issues/276 and https://github.com/yelouafi/redux-saga/issues/171.

My first idea was that variant 1 starts the second saga in the array when the first is completed, but you explicitly say that this is not the case:

We’re yielding an array with the results of the calls to the 2 sagas. This means the 2 resulting Generators will be started in parallel.

So what’s the difference? I did not find any hint in the docs, but maybe I overlooked something.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
smashercosmocommented, Sep 11, 2016

Starting rootSaga is still a big source of confusion to me. I asked a question about it on stackoverflow. http://stackoverflow.com/questions/39438005/what-is-the-idiomatic-way-of-starting-rootsaga. Would really appreciate, if someone gives a thorough answer.

1reaction
slorbercommented, Jun 25, 2016

@ms88privat I think it’s the same and the only difference is spawn is detached

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the idiomatic way of starting rootSaga? - Stack Overflow
Generally I'd recommend that you start multiple root sagas, or your parent saga uses spawn instead of fork so that your app remains...
Read more >
Root Saga
A root Saga aggregates multiple Sagas to a single entry point for the sagaMiddleware to run. In the beginner tutorial, it is shown...
Read more >
Redux Saga Explained: The redux-saga Tutorial - YouTube
Redux Saga allows for asynchronous behavior and so much more. We will wire up redux- saga and use it to manage the state...
Read more >
How to Ask When You Don't Know What to Ask - Atomic Spin
Here's a list of strategic questions that help me understand a problem when I'm not sure where to start. 1. Ask “Why?” This...
Read more >
Clarification of some concepts with regards to unit root and ...
A couple of issues that may help you to clarify your question: 1. I'm not 100% sure what you mean by "Auto-correlation tests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found