How does redux-saga handle callback?

25 Views Asked by At

I am learning Redux-Saga. I am trying to send a request then call a method to do something in my component. Below is my code:

function* getLeftCount({ payload: { query, callBackFun } }) {
  const data = yield call (apiService.getLeftCount, query);
  callBackFun (data.data.result);
}

then i will use takeLatest() to add it to saga.

however, it has an issue: if there are multiple same components and send requests at the same time. only one will get the callback work fine, others won't receive a callback.

if I use takeEvery(), it will work fine but send duplicated requests and cause waste.

are there any best practices to handle this scenario?

0

There are 0 best solutions below