const logger = store => next => action => {
let result
console.groupCollapsed("dispatching", action.type)
console.log('prev state', store.getState())
console.log('action', action)
result = next(action)
console.log('next state', store.getState())
console.groupEnd()
return result
}
const store = applyMiddleware(logger)(createStore)(
combineReducers({ colors, sort })
)
Would you please explain the above function with multiple arrows?
The code below:
const logger = store => next => action => { return 'something'; }
Is the equivalent of:
const logger = function(store) {
return function(next) {
return function(action) {
return 'something';
}
}
}
And it can be called like below:
var something = logger(store)(next)(action);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With