You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-4Lines changed: 43 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -31,9 +31,8 @@ RSAAs are identified by the presence of an `[RSAA]` property, where [`RSAA`](#rs
31
31
-[Bailing out](#bailing-out)
32
32
-[Lifecycle](#lifecycle)
33
33
-[Customizing the dispatched FSAs](#customizing-the-dispatched-fsas)
34
+
-[Dispatching Thunks](#dispatching-thunks)
34
35
-[Testing](#testing)
35
-
-[actions/user.js](#actionsuserjs)
36
-
-[actions/user.test.js](#actionsusertestjs)
37
36
-[Reference](#reference)
38
37
-[*Request* type descriptors](#request-type-descriptors)
39
38
-[*Success* type descriptors](#success-type-descriptors)
@@ -387,11 +386,51 @@ If a custom `payload` and `meta` function throws an error, `redux-api-middleware
387
386
388
387
A noteworthy feature of `redux-api-middleware` is that it accepts Promises (or function that return them) in `payload` and `meta` properties of type descriptors, and it will wait for them to resolve before dispatching the FSA — so no need to use anything like `redux-promise`.
389
388
389
+
### Dispatching Thunks
390
+
391
+
You can use `redux-thunk` to compose effects, dispatch custom actions on success/error, and implement other types of complex behavior.
392
+
393
+
See [the Redux docs on composition](https://github.com/reduxjs/redux-thunk#composition) for more in-depth information, or expand the example below.
To test `redux-api-middleware` calls inside our application, we can create a fetch mock in order to simulate the response of the call. The `fetch-mock` and `redux-mock-store`packages can be used for this purpose as shown in the following example:
0 commit comments