2021-09-13 20:41:05 +00:00
|
|
|
import { applyMiddleware, compose, createStore } from 'redux';
|
2017-08-16 22:51:37 +00:00
|
|
|
import createSagaMiddleware from 'redux-saga';
|
2018-04-24 19:34:03 +00:00
|
|
|
|
2022-04-07 14:19:54 +00:00
|
|
|
import reducers from '../../reducers';
|
|
|
|
import sagas from '../../sagas';
|
2020-05-08 17:04:37 +00:00
|
|
|
import applyAppStateMiddleware from './appStateMiddleware';
|
2017-08-13 01:35:09 +00:00
|
|
|
|
2018-03-23 16:55:40 +00:00
|
|
|
let sagaMiddleware;
|
|
|
|
let enhancers;
|
2017-08-13 01:35:09 +00:00
|
|
|
|
|
|
|
if (__DEV__) {
|
|
|
|
const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default();
|
2019-08-13 13:03:46 +00:00
|
|
|
const Reactotron = require('reactotron-react-native').default;
|
2018-03-23 16:55:40 +00:00
|
|
|
sagaMiddleware = createSagaMiddleware({
|
2018-07-17 19:10:27 +00:00
|
|
|
sagaMonitor: Reactotron.createSagaMonitor()
|
2018-03-23 16:55:40 +00:00
|
|
|
});
|
2017-09-25 13:15:28 +00:00
|
|
|
|
2018-03-23 16:55:40 +00:00
|
|
|
enhancers = compose(
|
2020-05-08 17:04:37 +00:00
|
|
|
applyAppStateMiddleware(),
|
2017-09-21 17:08:00 +00:00
|
|
|
applyMiddleware(reduxImmutableStateInvariant),
|
2019-08-07 13:51:34 +00:00
|
|
|
applyMiddleware(sagaMiddleware),
|
|
|
|
Reactotron.createEnhancer()
|
2017-09-21 17:08:00 +00:00
|
|
|
);
|
2017-08-13 01:35:09 +00:00
|
|
|
} else {
|
2018-03-23 16:55:40 +00:00
|
|
|
sagaMiddleware = createSagaMiddleware();
|
2021-09-13 20:41:05 +00:00
|
|
|
enhancers = compose(applyAppStateMiddleware(), applyMiddleware(sagaMiddleware));
|
2017-08-13 01:35:09 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 16:55:40 +00:00
|
|
|
const store = createStore(reducers, enhancers);
|
2017-08-17 00:24:06 +00:00
|
|
|
sagaMiddleware.run(sagas);
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
export default store;
|