Class 39: Remote CRUD Functionality with React, Redux and Thunk - mwilkin-401-advanced-javascript/bend-javascript-401d2 GitHub Wiki
For a Remote CRUD application, we need an API on the remote server to interact with the database.
Redux is unidirectional data flow.
Put another way, it is the source of truth on your application. It makes it easier to interact with state. By default, Redux actions are dispatched synchronously.This process flow becomes a problem when communicating with and external API because of their asynchronous behavior.
Redux thunk is a middleware of redux to make async calls. It takes your action, makes async call when response returns, calls the next chain of redux. As this diagram shows, it resides between the action being dispatched and the reducer.
action -> middleware(redux-thunk) -> reducer -> state -> View
Thunk allows action creators to be called which return a function instead of an action object.
That function receives the store’s dispatch method, which is then used to dispatch regular synchronous actions inside the body of the function once the asynchronous operations have completed.