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 })
)
您能用多个箭头解释以上功能吗?
下面的代码:
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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句