Louis Lecocq
Louis Lecocq

Reputation: 1814

How to implement Sequential loop in Redux Saga

I'm trying to implement a loop that calls another saga in a loop using Redux-saga. I don't want it to be parallels so i don't want to use yield all.

limits.forEach((limit) => yield call(setupLimit, accountId, limit));

Here my limits is an array of limit and i need to call an API (which is handled the function* setupLimit).

I also need to pass two arguments to this setupLimit which are accountId and the limit.

I do not succeed to run it. Any help is welcome

Upvotes: 1

Views: 662

Answers (1)

Aleksey L.
Aleksey L.

Reputation: 38046

You can use regular for...of loop:

for(const limit of limits) {
    yield call(setupLimit, accountId, limit);
}

Upvotes: 3

Related Questions