Redux blocking next middleware
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.4/redux.js"></script>
JavaScript
// open console
(function() {
function middleWareOne(store) {
return function(next) {
return function(action) {
return next({type:(action.type + "1")});
}
}
}
function middleWareTwo(store){
return function(next){
return function(action){
return next({type:(action.type + "2")});
}
}
}
function middleWareThree(store){
return function(next){
return function(action){
//return next({type:(action.type + "3")});
}
}
}
function rootReducer(state, action) {
console.log("Inside the rootReducer", action);
return {
date: new Date()
};
}
var createStoreWithMiddleware = Redux.applyMiddleware(middleWareOne, middleWareTwo, middleWareThree)(Redux.createStore);
var store = createStoreWithMiddleware(rootReducer)
store.subscribe(function() {
console.log("current state", store.getState());
});
store.dispatch({
type: "whatever"
});
})();