Side Effects in Middleware
Explore how to handle side effects in Redux by implementing middleware. Understand the advantages of triggering side effects through actions, improving debugging and scalability by separating business logic into dedicated middleware.
We'll cover the following...
We'll cover the following...
In the previous lesson, we implemented a flow to handle side effects in action creators. Let’s take a moment and implement the exact same flow, this time in a middleware:
//Handling side effects in middleware
const cartMiddleware = ({ dispatch, getState }) => next => action => {
next(action);
if (action.type === ...