2022-08-04 13:31:14 +02:00
|
|
|
import { applyMiddleware, legacy_createStore as createStore, compose as reduxCompose } from 'redux';
|
2019-08-31 04:07:25 +05:00
|
|
|
import createSagaMiddleware from 'redux-saga';
|
2022-12-15 01:34:48 +01:00
|
|
|
import { createRouterMiddleware } from './lib/redux-router';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
import rootReducer from './reducers';
|
|
|
|
import rootSaga from './sagas';
|
2022-12-15 01:34:48 +01:00
|
|
|
import history from './history';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
const sagaMiddleware = createSagaMiddleware();
|
|
|
|
|
2022-12-15 01:34:48 +01:00
|
|
|
const middlewares = [sagaMiddleware, createRouterMiddleware(history)];
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2021-02-15 14:14:43 -08:00
|
|
|
let compose = reduxCompose;
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
const { logger } = require('redux-logger'); // eslint-disable-line global-require
|
|
|
|
middlewares.push(logger);
|
2021-02-15 14:14:43 -08:00
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
// Enable Redux Devtools in development
|
2021-02-15 14:14:43 -08:00
|
|
|
// https://github.com/zalmoxisus/redux-devtools-extension
|
|
|
|
if (typeof window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ !== 'undefined') {
|
|
|
|
compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
|
|
|
}
|
2019-08-31 04:07:25 +05:00
|
|
|
}
|
|
|
|
|
2022-12-15 01:34:48 +01:00
|
|
|
export default createStore(rootReducer, compose(applyMiddleware(...middlewares)));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
sagaMiddleware.run(rootSaga);
|