Created
May 28, 2019 13:37
-
-
Save Tiagoperes/e433616be30cf35bb55b1b497d2bdb13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore, applyMiddleware, combineReducers } from 'redux' | |
| import createSagaMiddleware from 'redux-saga' | |
| import resources from './resources' | |
| import cacheManager from './cache' | |
| import { createEffects, getTypeToSagaMap } from '@zup-next/redux-resource' | |
| import { mapValues } from 'lodash' | |
| const reducers = combineReducers(mapValues(resources, 'reducer')) | |
| export const rootSaga = function* run() { | |
| yield createEffects(getTypeToSagaMap(mapValues(resources, 'sagas'))) | |
| } | |
| const sagaMiddleware = createSagaMiddleware() | |
| const store = createStore( | |
| reducers, | |
| applyMiddleware(cacheManager.getMiddleware(), sagaMiddleware), | |
| ) | |
| sagaMiddleware.run(rootSaga) | |
| export default store |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment