Performance Optimization by Conditional Monitoring
Illustrates how to enable SagaMonitor conditionally, reducing performance overhead in production environments.
const enableSagaMonitor = process.env.NODE_ENV === 'development';
Conditionally enable the SagaMonitor based on the environment.
const sagaMiddlewareOptions = enableSagaMonitor ? { sagaMonitor: console.tron.createSagaMonitor() } : {};
Configure saga middleware options with SagaMonitor if enabled. Replace 'console.tron.createSagaMonitor()' with your SagaMonitor creation logic.
import createSagaMiddleware from 'redux-saga';
const sagaMiddleware = createSagaMiddleware(sagaMiddlewareOptions);
Create the saga middleware with the conditional SagaMonitor option.