Adding Asynchronous Actions to Redux

When we last looked at our asynchronous actions before we added in Redux, what we basically had was a combination of our ActionCable calls and our reducer calls. The problem with this is that the combination is somewhat awkward and requires always remembering that the two parts need to be called together. What we really want is for our store, which is now provided by Redux, to allow us to mix these asynchronous actions with our regular reducer calls.

To do this, we are going to use an add-on to Redux called Redux Thunk.[84] Redux Thunk is actually based on a pretty small idea. Up until now, the actions we’ve been passing to our reducer have just been data objects. What Redux Thunk asks is, “What if those ...

Get Modern Front-End Development for Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.