forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigureStore.js
More file actions
57 lines (41 loc) · 1.31 KB
/
configureStore.js
File metadata and controls
57 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {createStore, applyMiddleware} from 'redux';
import thunkMiddleware from 'redux-thunk';
import promiseMiddleware from './promiseMiddleware';
import asyncActionCallbackMiddleware from './asyncActionCallbackMiddleware';
import utilsMiddleware from './utilsMiddleware';
import minPendingTimeMiddleware from './minPendingTime';
import syncReducerToAsyncStorage from './syncReducerToAsyncStorage';
import createLogger from 'redux-logger';
import reducers from '../reducers';
const isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;
const logger = createLogger({
predicate: (getState, action) => isDebuggingInChrome,
collapsed: true,
duration: true
});
let middlewares = [
thunkMiddleware,
promiseMiddleware,
asyncActionCallbackMiddleware,
minPendingTimeMiddleware,
utilsMiddleware,
syncReducerToAsyncStorage
];
if (isDebuggingInChrome) {
// middlewares.push(logger);
}
export default function configureStore(initialState) {
const store = applyMiddleware(
...middlewares
)(createStore)(reducers, initialState, window.devToolsExtension && window.devToolsExtension());
if (module.hot) {
module.hot.accept(() => {
const nextRootReducer = require('../reducers/index').default;
store.replaceReducer(nextRootReducer);
});
}
if (isDebuggingInChrome) {
window.store = store;
}
return store;
}