happypoulp / redux-tutorial

Learn how to use redux step by step
3.76k stars 546 forks source link

why does the middleware have three levels #48

Closed mukeshsoni closed 9 years ago

mukeshsoni commented 9 years ago

Why does the second level function (which is passed the next function ref) needed? The way applyMiddleware works, the dispatch functions returned by the middleware are stored as such -

store.dispatch = middleware(store)(store.dispatch);

Why can't the next be simply passed as the second parameter in the first middleware function call?

gaearon commented 9 years ago

No particular reason. We might choose to fix this later: https://github.com/rackt/redux/pull/784

mukeshsoni commented 9 years ago

got it. Thanks!