Answer the question
In order to leave comments, you need to log in
Redux-saga: how to call callback after executing multiple Ajax requests from different sagas?
Greetings!
Stack: react, redux, redux-saga.
Problem: there is a preloader and a bunch of ajax requests that are distributed over different sagas. 1 request controls 1 saga. How can I wait for each of these requests to complete and call the callback?
Purpose: hide the preloader only after successful or unsuccessful execution of each request.
I really hope for help.
Answer the question
In order to leave comments, you need to log in
Solved a similar problem.
There is an option.
The problem is that requests are asynchronous and we cannot predict which ones will be slower and which ones will be faster.
An option to solve this problem is to create a pair of Ashns, BEGIN_FETCHING and END_FETCHING.
Add an object to the store that would accumulate the download process, by default it is 0.
At the beginning of the request, we do
yield put({
type: BEGIN_FETCHING
})
yield put({
type: END_FETCHING
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question