Why do we do this:
const middleware = store => next => action => { ... }
and not something simpler like
const middleware = (store, next, action) => { ... }
Was there some advantage to the Redux team for designing middleware this way? Is there some functionality we can take advantage of if we split up the middleware functions?
In my own applications I've defined a simplerMiddleware()
function that can convert from the second form to the first and it seems to work well.
function simpleMiddleware(simpleMiddlewareFunction) {
return store => next => action => simpleMiddlewareFunction(store, next, action);
}
Why the three arrow functions?
Note: I'm not asking what is currying or why currying exists in functional programming or what are the generic benefits of currying; was there a specific reason the Redux designers chose this signature over a simpler three argument function?