[Upgrade] Enable redux-saga
This commit is contained in:
@@ -3,6 +3,7 @@ import * as redux from 'redux'
|
||||
import thunk from 'redux-thunk'
|
||||
import { routerMiddleware } from 'react-router-redux'
|
||||
import createHistory from 'history/createBrowserHistory'
|
||||
import createSagaMiddleware, { END } from 'redux-saga'
|
||||
import { createLogger } from 'redux-logger'
|
||||
import { rootReducer } from 'reducers'
|
||||
import DevTools from './devTools'
|
||||
@@ -11,7 +12,7 @@ export const history = createHistory()
|
||||
|
||||
// - Build the middleware for intercepting and dispatching navigation actions
|
||||
const logger = createLogger()
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware()
|
||||
// - initial state
|
||||
let initialState = {
|
||||
|
||||
@@ -19,8 +20,8 @@ let initialState = {
|
||||
|
||||
// - Config and create store of redux
|
||||
let store: redux.Store<any> = redux.createStore(rootReducer, initialState, redux.compose(
|
||||
redux.applyMiddleware(logger,thunk, routerMiddleware(history)),
|
||||
redux.applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware),
|
||||
DevTools.instrument()
|
||||
))
|
||||
|
||||
export default {store, history}
|
||||
export default {store, runSaga: sagaMiddleware.run, close: () => store.dispatch(END), history}
|
||||
|
||||
@@ -3,14 +3,13 @@ import * as redux from 'redux'
|
||||
import thunk from 'redux-thunk'
|
||||
import { routerMiddleware } from 'react-router-redux'
|
||||
import createHistory from 'history/createBrowserHistory'
|
||||
import createSagaMiddleware, { END } from 'redux-saga'
|
||||
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 sagaMiddleware = createSagaMiddleware()
|
||||
// - initial state
|
||||
let initialState = {
|
||||
|
||||
@@ -18,8 +17,7 @@ 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
|
||||
redux.applyMiddleware(thunk, routerMiddleware(history), sagaMiddleware)
|
||||
))
|
||||
|
||||
export default {store, history}
|
||||
export default {store, runSaga: sagaMiddleware.run, close: () => store.dispatch(END), history}
|
||||
|
||||
@@ -4266,10 +4266,6 @@ lodash.flow@^3.3.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a"
|
||||
|
||||
lodash.isequal@^4.0.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
|
||||
|
||||
lodash.isfunction@^3.0.8:
|
||||
version "3.0.9"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051"
|
||||
|
||||
Reference in New Issue
Block a user