forked from InconspicuousPaprika/Car.ly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configureStore.js
37 lines (33 loc) · 1002 Bytes
/
configureStore.js
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
import Immutable from 'immutable';
import { Platform } from 'react-native';
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import reducer from './reducers';
import promiseMiddleware from 'redux-promise';
const middlewares = [thunk];
let enhancer;
if (__DEV__) {
const installDevTools = require('immutable-devtools');
installDevTools(Immutable);
const devTools = require('remote-redux-devtools');
enhancer = compose(
applyMiddleware(...middlewares, promiseMiddleware),
devTools({
name: Platform.OS,
hostname: 'localhost',
port: 5678
})
);
} else {
enhancer = applyMiddleware(...middlewares);
}
export default function configureStore(initialState) {
const store = createStore(reducer, initialState, enhancer);
if (module.hot) {
module.hot.accept(() => {
// combines all the reducers in the file and attaches it to
store.replaceReducer(require('./reducers'));
});
}
return store;
}