Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
“demos” sagas where running twice. Once from the calls to createStore…
Browse files Browse the repository at this point in the history
… and one from the call to inject the “dashboard” sagas in Dashboard.js.

now instead there are registered as the dashbord sagas, ensuring they run only once.
#107
  • Loading branch information
Frederic Lavigne committed Jan 27, 2017
1 parent cb101b6 commit 7879bc3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/modules/demos.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function *watchEndDemoSession() {
yield call(api.endDemo, demoState.guid, demoState.token);
}
catch (error) {
console.log('ERROR DURING LOGOUT: probably because we are calling logout twice. BUG');
console.log('Error during logout', error);
}
window.localStorage.removeItem('savedGuid');
yield put(push('/'));
Expand Down
6 changes: 5 additions & 1 deletion src/store/createStore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { applyMiddleware, compose, createStore } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import createSagaMiddleware from 'redux-saga';
import { sagas as demosSagas } from 'modules/demos';
import makeRootReducer from './reducers';
import makeRootSaga from './sagas';
import { makeRootSaga, injectSagas } from './sagas';

export default (initialState = {}, history) => {
// ======================================================
Expand Down Expand Up @@ -40,6 +41,9 @@ export default (initialState = {}, history) => {
};
store.runSaga(makeRootSaga(store.asyncSagas));

// inject the base sagas to login/logout of a demo session
injectSagas(store, { key: 'demos', sagas: demosSagas });

if (module.hot) {
module.hot.accept('./reducers', () => {
const reducers = require('./reducers').default;
Expand Down
3 changes: 0 additions & 3 deletions src/store/sagas.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { fork } from 'redux-saga/effects';

const demosSagas = require('modules/demos').sagas;

export const makeRootSaga = asyncSagas => function *rootSaga() {
yield [
...demosSagas,
...asyncSagas,
].map(saga => fork(saga));
};
Expand Down

0 comments on commit 7879bc3

Please sign in to comment.