pixelprodotco
5/13/2017 - 10:27 PM

Example store index file

Example store index file

import { applyMiddleware, createStore, combineReducers } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import AccountReducer from './reducers/account'
import AppReducer from './reducers/app'
import BusinessUnitReducer from './reducers/businessUnit'
import createSagaMiddleware from 'redux-saga'
import LicenseReducer from './reducers/license'
import PackageReducer from './reducers/package'
import PromptReducer from './reducers/prompt'
import ProvisionReducer from './reducers/provision'
import ToastReducer from './reducers/toast'
import rootSaga from './rootSaga'
import UserReducer from './reducers/user'

const reducers = combineReducers({
  account: AccountReducer,
  app: AppReducer,
  businessUnit: BusinessUnitReducer,
  license: LicenseReducer,
  package: PackageReducer,
  prompt: PromptReducer,
  provision: ProvisionReducer,
  toast: ToastReducer,
  user: UserReducer
})

const sagaMiddleware = createSagaMiddleware()
export function generateStore (mode = process.env.NODE_ENV) {
  return mode === 'development'
    ? createStore(reducers, composeWithDevTools(applyMiddleware(sagaMiddleware)))
    : createStore(reducers, applyMiddleware(sagaMiddleware))
}
const State = generateStore()
sagaMiddleware.run(rootSaga)
export default State