|
@@ -58,18 +58,53 @@ function * rootSaga () {
|
|
|
/** Create the saga middleware */
|
|
|
const sagaMiddleware = createSagaMiddleware()
|
|
|
|
|
|
+const logger = store => next => action => {
|
|
|
+ console.log('dispatching', action)
|
|
|
+ let result = next(action)
|
|
|
+ console.log('next state', store.getState())
|
|
|
+ return result
|
|
|
+}
|
|
|
+
|
|
|
+const crashReporter = store => next => action => {
|
|
|
+ try {
|
|
|
+ return next(action)
|
|
|
+ } catch (err) {
|
|
|
+ console.error('Caught an exception!', err)
|
|
|
+ throw err
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const middleware = [
|
|
|
+ logger,
|
|
|
+ crashReporter,
|
|
|
+ alerts.middleware,
|
|
|
+ sagaMiddleware
|
|
|
+]
|
|
|
/** The enhancer allows to use Redux development tools in Chrome */
|
|
|
-const enhancers = compose(
|
|
|
- applyMiddleware(alerts.middleware),
|
|
|
- applyMiddleware(sagaMiddleware),
|
|
|
- window.devToolsExtension ? window.devToolsExtension() : f => f
|
|
|
-)
|
|
|
-console.log('Enhancers:', enhancers)
|
|
|
+// see: https://github.com/zalmoxisus/redux-devtools-extension/issues/220
|
|
|
+let enhancer
|
|
|
+if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
|
|
|
+ enhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(
|
|
|
+ applyMiddleware(...middleware)
|
|
|
+ )
|
|
|
+} else {
|
|
|
+ enhancer = compose(
|
|
|
+ applyMiddleware(...middleware)
|
|
|
+ )
|
|
|
+}
|
|
|
+// const enhancer = compose(
|
|
|
+// applyMiddleware(alerts.middleware),
|
|
|
+// applyMiddleware(sagaMiddleware),
|
|
|
+// applyMiddleware(logger),
|
|
|
+// applyMiddleware(crashReporter),
|
|
|
+// window.devToolsExtension ? window.devToolsExtension() : f => f
|
|
|
+// )
|
|
|
+console.log('Enhancers:', enhancer)
|
|
|
|
|
|
/** Build the Redux store from the rootReducer, the defualtState and the enhancers. */
|
|
|
-const store = createStore(rootReducer, defaultState, enhancers)
|
|
|
-sagaMiddleware.run(rootSaga)
|
|
|
+const store = createStore(rootReducer, defaultState, enhancer)
|
|
|
console.log('Store:', store)
|
|
|
+sagaMiddleware.run(rootSaga)
|
|
|
/** react-route is not used in this project.
|
|
|
const history = syncHistoryWithStore(browserHistory, store)
|
|
|
console.log('history:', history)
|