Reading 38 Remote APIs - liz-kavalski-401-advanced-javascript/seattle-javascript-401n13 GitHub Wiki
Async Actions
Two crucial moments in time: the moment you start the call, and the moment when you receive an answer (or a timeout).
Need to dispatch normal actions that will be processed by reducers synchronously.
The API request you'll want to dispatch at least three different kinds of actions.
An action informing the reducers that the request began.
The reducers may handle this action by toggling an isFetching flag in the state. This way the UI knows it's time to show a spinner.
An action informing the reducers that the request finished successfully.
The reducers may handle this action by merging the new data into the state they manage and resetting isFetching. The UI would hide the spinner, and display the fetched data.
An action informing the reducers that the request failed.
The reducers may handle this action by resetting isFetching. Additionally, some reducers may want to store the error message so the UI can display it.