Skip to content Skip to sidebar Skip to footer

Why Curry Redux Middleware: State => Next => Action {} Vs. (state, Next) => Action {}

After reading both Redux's documentation on middleware and source code on applyMiddleware, I don't understand why middleware need the curry syntax: const logger = store => next

Solution 1:

A discussion with Dan Abramov can be found here regarding this. He said,

We could have made it (store, next) => action => () but I don't see a problem with just going all the way. You might want some configuration later, at which point options => (store, next) => action => () looks kinda arbitrary.

So no, it is not necessary to curry the parameters.

Solution 2:

No, because it a way to defer an function to be executed later. ()=>() returns a function object which only get executed later when the func obj is called.

Post a Comment for "Why Curry Redux Middleware: State => Next => Action {} Vs. (state, Next) => Action {}"