Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

343
Vistas
Events handled by another saga (Redux-Saga)

I'm trying to create an error interceptor for all my sagas, after analyzing the redux-saga eventChannel I tried to create a saga like this:

export function interceptor() {
  return eventChannel(() => {
    api.interceptors.response.use(
      (response) => response,

      (error) => {
        const { response } = error;

        if ([401, 403].includes(response.status)) {
            emit(AuthCreators.logoutRequest());
        }

        return Promise.reject(error);
      }
    );

    return () => null;
  });
}

In rootSaga it is being called this way:

export default function* rootSaga() {
    return yield all([fork(interceptor), anotherSaga, anotherSaga2]);
}

This way, every time one of my other sagas has a catch the interceptor is triggered, however my emit that should trigger the logoutRequest that is in other saga is not being triggered.

  • How can the emit call other saga?
  • Is this the best way to create an error interceptor?

Already grateful

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Maybe I don't understand you question exactly but this might help you

const saga = [
anotherSaga, anotherSaga2
]

yield all(sagas.map((saga) => spawn(function* () {
        try {
            yield call(saga);
        } catch (e) {
            // console.log(e);
            // here we should store all errors in some service...
        }
    })));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda