Advanced Redux — Side Effects, Async Tasks & ThunksEntry 8 of 9
Choosing an Async Approach
Redux offers several places for async logic; the right one depends on how complex and reused the logic is.
Notes
useEffectin a component: quickest, but couples the component to HTTP details. Fine for one-off cases.- Custom thunk: multi-step flows (notifications + request + several dispatches) shared across components.
createAsyncThunk: one request mapped to one slice's loading/data/error state. The default for most data fetching.- RTK Query (
createApi): server data with caching, deduplication, and refetching built in. Replaces most hand-written fetching thunks in larger apps. - Redux Saga: generator-based middleware for complex workflows (cancellation, races). Rarely needed with RTK.
What / Why / When
- What
A decision guide.
- Why
Matching the tool to the job avoids both boilerplate and spaghetti components.
- When
Before writing any new async logic.
Quick reference
| Need | Redux Toolkit | Angular |
|---|---|---|
| One-off side effect | useEffect in component | Service call in component (non-store data) |
| Multi-step async flow | Custom thunk | Effect (chain actions) |
| One request → one state slice | createAsyncThunk | Action group + effect |
| Cached server data | RTK Query | httpResource() / resource() |
| Complex workflows | Redux Saga / listener middleware | Effects with RxJS operators |