React-boilerplate: Duplicated sagas running in background

Created on 4 Jul 2016  路  2Comments  路  Source: react-boilerplate/react-boilerplate

I think there's something wrong with async sagas injection
Say we have the following route:

 getComponent(nextState, cb) {
        const importModules = Promise.all([
          System.import('containers/HomePage/reducer'),
          System.import('containers/HomePage/sagas'),
          System.import('containers/HomePage'),
        ]);

        const renderRoute = loadModule(cb);

        importModules.then(([reducer, sagas, component]) => {
          injectReducer('home', reducer.default);
          injectSagas(sagas.default);

          renderRoute(component);
        });

        importModules.catch(errorLoading);
      }

The problem is every time home route got hit home sagas would be injected and run again and we end up have duplicated sagas running in background .
I don't know if it's the expected behavior !

Most helpful comment

That's what this is for in the saga:

  yield take(LOCATION_CHANGE);
  yield cancel(watcher);

All 2 comments

That's what this is for in the saga:

  yield take(LOCATION_CHANGE);
  yield cancel(watcher);

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theterra picture theterra  路  3Comments

gihrig picture gihrig  路  3Comments

arthurCormack picture arthurCormack  路  3Comments

smiile picture smiile  路  3Comments

chaintng picture chaintng  路  4Comments