[Improvement] Add config store for different environments

This commit is contained in:
Qolzam
2018-03-17 19:00:58 +07:00
parent a130e89248
commit 46784208f2
3 changed files with 58 additions and 25 deletions

View File

@@ -0,0 +1,27 @@
// - Import external components
import * as redux from 'redux'
import thunk from 'redux-thunk'
import { routerMiddleware } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
import { createLogger } from 'redux-logger'
import { rootReducer } from 'reducers'
// Create a history of your choosing (we're using a browser history in this case)
export const history = createHistory()
// - Build the middleware for intercepting and dispatching navigation actions
const middleware = routerMiddleware(history)
const logger = createLogger()
// - initial state
let initialState = {
}
// - Config and create store of redux
let store: redux.Store<any> = redux.createStore(rootReducer, initialState, redux.compose(
redux.applyMiddleware(logger,thunk,middleware),
(window as any).devToolsExtension ? (window as any).devToolsExtension() : (f: any) => f
))
export default store

View File

@@ -0,0 +1,25 @@
// - Import external components
import * as redux from 'redux'
import thunk from 'redux-thunk'
import { routerMiddleware } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
import { rootReducer } from 'reducers'
// Create a history of your choosing (we're using a browser history in this case)
export const history = createHistory()
// - Build the middleware for intercepting and dispatching navigation actions
const middleware = routerMiddleware(history)
// - initial state
let initialState = {
}
// - Config and create store of redux
let store: redux.Store<any> = redux.createStore(rootReducer, initialState, redux.compose(
redux.applyMiddleware(thunk,middleware),
(window as any).devToolsExtension ? (window as any).devToolsExtension() : (f: any) => f
))
export default store

View File

@@ -1,27 +1,8 @@
// - Import external components
import * as redux from 'redux'
import thunk from 'redux-thunk'
import { routerMiddleware } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
import { createLogger } from 'redux-logger'
import { rootReducer } from 'reducers'
import configureStoreDev from './configureStore.dev'
import configureStoreProd from './configureStore.prod'
// Create a history of your choosing (we're using a browser history in this case)
export const history = createHistory()
const store = process.env.NODE_ENV === 'production'
? configureStoreDev
: configureStoreProd
// - Build the middleware for intercepting and dispatching navigation actions
const middleware = routerMiddleware(history)
const logger = createLogger()
// - initial state
let initialState = {
}
// - Config and create store of redux
let store: redux.Store<any> = redux.createStore(rootReducer, initialState, redux.compose(
redux.applyMiddleware(logger,thunk,middleware),
(window as any).devToolsExtension ? (window as any).devToolsExtension() : (f: any) => f
))
export default store
export default store