Blog>
Snippets

Using all Effect for Parallel Task Execution

Provide an example of how to use the `all` effect for running multiple sagas in parallel within the Root Saga, for efficient task management.
import { all, fork } from 'redux-saga/effects';
import { fetchUsersSaga } from './sagas/fetchUsersSaga';
import { fetchProductsSaga } from './sagas/fetchProductsSaga';
First, import the necessary effects from redux-saga and the sagas you want to run in parallel.
function* rootSaga() {
  yield all([
    fork(fetchUsersSaga),
    fork(fetchProductsSaga)
  ]);
}
Define the rootSaga that uses the all effect to run multiple sagas in parallel. The fork effect is used to start each saga in a non-blocking manner.
export default rootSaga;
Export the rootSaga to use in your Redux Saga middleware configuration.