To define a middleware in redux we need to write a cascade of functions like:
const middleware = middlewareApi => next => action => {
//logic here
}
The question is whether this signature is:
- imposed by any necessities / opens any opportunities;
- just the implication of Redux's implementation details / comfortable for developers to manipulate an array of
(next)
-argumented functions like here
Could it be replaced with the following signature (with with corresponding changes to Redux's code of course):
const middleware = (middlewareApi, next) => action => {
//logic here
}
I realize that the result not totally equivalent to the former one but doesn't seem it makes any difference for the applyMiddleware
case. The benefit that this syntax is less confusing IMO.