The compose
function in Redux is really simple for the most part and I understand how to use it.
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)))
}
However, this one part of the last bit seems really obscure to me:
funcs.reduce((a, b) => (...args) => a(b(...args)))
What is the ...args
part? I understand these are rest parameters but what is it evaluating to? Where is it coming from?