[Redux] Setup redux-saga

This commit is contained in:
Bruno Lemos
2018-10-20 13:22:59 -03:00
parent 6f603be6b3
commit 8e56b69441
4 changed files with 22 additions and 2 deletions

View File

@@ -41,6 +41,7 @@
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.5",
"redux-persist": "^5.10.0",
"redux-saga": "^0.16.2",
"warna": "^0.2.4"
},
"devDependencies": {

5
src/redux/sagas/index.ts Normal file
View File

@@ -0,0 +1,5 @@
import { all } from 'redux-saga/effects'
export function* rootSaga() {
yield all([])
}

View File

@@ -1,16 +1,25 @@
import { createStore } from 'redux'
import { applyMiddleware, createStore } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import { persistReducer, persistStore } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import createSagaMiddleware from 'redux-saga'
import { rootReducer } from './reducers'
import { rootSaga } from './sagas'
export function configureStore(key = 'root') {
const persistConfig = { key, storage }
const persistedReducer = persistReducer(persistConfig, rootReducer)
const store = createStore(persistedReducer, composeWithDevTools())
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
persistedReducer,
composeWithDevTools(applyMiddleware(sagaMiddleware)),
)
const persistor = persistStore(store)
sagaMiddleware.run(rootSaga)
return { store, persistor }
}

View File

@@ -5960,6 +5960,11 @@ redux-persist@^5.10.0:
resolved "https://registry.npmjs.org/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b"
integrity sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg==
redux-saga@^0.16.2:
version "0.16.2"
resolved "https://registry.npmjs.org/redux-saga/-/redux-saga-0.16.2.tgz#993662e86bc945d8509ac2b8daba3a8c615cc971"
integrity sha512-iIjKnRThI5sKPEASpUvySemjzwqwI13e3qP7oLub+FycCRDysLSAOwt958niZW6LhxfmS6Qm1BzbU70w/Koc4w==
redux@^4.0.0, redux@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"