Skip to content

Commit cd3c210

Browse files
committed
Add async data flow diagram
1 parent 3921125 commit cd3c210

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

docs/tutorials/essentials/part-5-async-logic.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ But, what if you want to have async logic interact with the store by dispatching
6565

6666
There are many kinds of async middleware for Redux, and each lets you write your logic using different syntax. The most common async middleware is [`redux-thunk`](https://github.com/reduxjs/redux-thunk), which lets you write plain functions that may contain async logic directly. Redux Toolkit's `configureStore` function [automatically sets up the thunk middleware by default](https://redux-toolkit.js.org/api/getDefaultMiddleware#included-default-middleware), and [we recommend using thunks as the standard approach for writing async logic with Redux](../../style-guide/style-guide.md#use-thunks-for-async-logic).
6767

68+
Earlier, we saw [what the synchronous data flow for Redux looks like](part-1-overview-concepts.md#redux-application-data-flow). When we introduce asynchronous logic, we add an extra step where middleware can run logic like AJAX requests, then dispatch actions. That makes the async data flow look like this:
69+
70+
![Redux async data flow diagram](/img/tutorials/essentials/ReduxAsyncDataFlowDiagram.gif)
71+
6872
### Thunk Functions
6973

7074
Once the thunk middleware has been added to the Redux store, it allows you to pass _thunk functions_ directly to `store.dispatch`. A thunk function will always be called with `(dispatch, getState)` as its arguments, and you can use them inside the thunk as needed.

docs/tutorials/fundamentals/part-6-async-logic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ Just like with a normal action, we first need to handle a user event in the appl
155155

156156
Once that dispatched value reaches a middleware, it can make an async call, and then dispatch a real action object when the async call completes.
157157

158-
Earlier, we saw [a diagram that represents the normal synchronous Redux data flow](./part-2-concepts-data-flow.md#redux-application-data-flow). When we add async logic to a Redux app, the data flow sequence now looks like this:
158+
Earlier, we saw [a diagram that represents the normal synchronous Redux data flow](./part-2-concepts-data-flow.md#redux-application-data-flow). When we add async logic to a Redux app, we add an extra step where middleware can run logic like AJAX requests, then dispatch actions. That makes the async data flow look like this:
159159

160-
**FIXME Add async Redux data flow diagram here**
160+
![Redux async data flow diagram](/img/tutorials/essentials/ReduxAsyncDataFlowDiagram.gif)
161161

162162
## Using the Redux Thunk Middleware
163163

6.35 MB
Loading

0 commit comments

Comments
 (0)