brianegan / redux_thunk

Redux Middleware for handling functions as actions
MIT License
88 stars 8 forks source link

With redux_thunk, do I need middleware to make async operations? #10

Closed rubensdemelo closed 5 years ago

rubensdemelo commented 5 years ago

Once I can dispach an async request in my action, what is middleware function?

yoavrofe commented 5 years ago

With the redux_thunk middleware, you don't need other middleware to make async calls. See the demo in README.md, and also my addition here: https://github.com/brianegan/redux_thunk/pull/9/commits/53098991bfc4482c22ea8a699ef9a18ba91f9342

brianegan commented 5 years ago

Hey sorry -- somehow missed this one...

Yah, folks in the JS community invented Thunks as an alternative to Middleware for async tasks, so as @yoavrofe has said, you shouldn't need both a Thunk and a Middleware for the same async task.

rubensdemelo commented 5 years ago

Thank you for reply guys. So, a good practice to follow the redux pattern is use middleware for async calls, correct ? ( I can make async calls in action without redux_thunk or middleware, but it isnt the normal flow ).