了解嵌套箭头函数ES6 [英] Understanding nested arrow functions ES6
本文介绍了了解嵌套箭头函数ES6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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?
推荐答案
以下代码:
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);
这篇关于了解嵌套箭头函数ES6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文