Flow Control
Explore how Redux middleware manages and controls application flow by reacting to dispatched actions. Understand how to streamline complex async workflows like user login by centralizing related actions in middleware, improving code reuse and maintainability.
We'll cover the following...
We'll cover the following...
One important usage of middleware is to control the application’s flow and logic. Let’s consider a sample user login flow:
- Send
POSTrequest to the server to log in - Save access token in store
- Fetch current user’s profile information
- Fetch the latest notifications
Usually, our flow will begin with a LOGIN action containing the login credentials:
{
type: 'LOGIN',
payload: {
email: 'info@redux-book.com',
password: 'will-never-tell'
}
}
...