kenberkeley / redux-simple-tutorial

Redux 简明教程。本教程深入浅出,配套入门、进阶源码解读以及文档注释丰富的 Demo 等一条龙服务

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于compose的一点疑问

zgw010 opened this issue · comments

commented

现在官方的compose源码中关于reduceRight这段变成了
return funcs.reduce((a, b) => (...args) => a(b(...args)))
reduce不应该是从左到右执行的吗?
为什么这里换了reduce还可以做到compose(f, g, h)(...arg) => f(g(h(...args)))的效果?
感觉这个issue不应该在这提,但是找了一晚上也没弄明白,希望能有人解答.

因为 f(g(h(...args))h 先执行,结果传入 g;而 g 的执行结果又传入 f