Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middlewares are applied in last-in-first-out order #28

Closed
AmaranthineCodices opened this issue May 5, 2018 · 2 comments
Closed

Middlewares are applied in last-in-first-out order #28

AmaranthineCodices opened this issue May 5, 2018 · 2 comments

Comments

@AmaranthineCodices
Copy link
Contributor

This is a tripup in how middlewares are applied. This ordering of middlewares:

{ middlewareA, middlewareB, middlewareC }

is invoked like this:

dispatch(middlewareA(middlewareB(middlewareC(action))))

in short, they're being applied in reverse order. This is not intuitive behavior; middlewares should be applied in first-in-first-out order, so the middlewares above would be invoked like:

dispatch(middlewareC(middlewareB(middlewareA(action))))
@LPGhatguy
Copy link
Contributor

I feel like both orders are still pretty confusing. Someone is always going to feel that they're backwards!

The current order lines up with functional composition syntax in mathematics, like f ∘ g being f(g(x)).

@LPGhatguy
Copy link
Contributor

We fixed this in #29!

Everyone was very confused with regards to this, but you were totally right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants