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 })
)
请您用多个箭头解释上述功能吗?
答案 0 :(得分:15)
以下代码:
const logger = store => next => action => { return 'something'; }
相当于:
const logger = function(store) {
return function(next) {
return function(action) {
return 'something';
}
}
}
可以像下面这样调用:
var something = logger(store)(next)(action);