likes
comments
collection
share

Redux compose

作者站长头像
站长
· 阅读数 48

读的比较好的一篇文章:

https://www.jianshu.com/p/c9d...

export default function compose(...funcs) {
  if (funcs.length === 0) {
    return arg => arg
  }

  if (funcs.length === 1) {
    return funcs[0]
  }

  return funcs.reduce((a, b) => (...args) => a(b(...args)))
}

compose(f1, f2, f3, f4)(args)

执行顺序是 : f1(f2(f3(f4(args))))

转载自:https://segmentfault.com/a/1190000042008474
评论
请登录