Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!