Class Thirty-Eight Notes (401)
Redux - Asynchronous Actions
async actions
- Redux middleware is designed to enble writing logic with side effects such as async funcitons.
- A client sends in an event that triggers an action which is then dispatched by the event handler. The event is then passed on to the middleware which is designed to be blocking until the API call is complete, then the response is dispatched with the action to the store which then state is updated by the reducer. The respose is passed backt ro the client.
thunk middleware
- Redux thunk middleware is used to allow functions with logic inside the functions to interact with a Redux store’s dispatch and getState methods.
- Redux Thunk middleware allows you to write action creators that return a function instead of an action.
- Any return value from the inner thunk function will be made available as the return value of dispatch itself
Back to main page
References