Search code examples
react-nativereact-reduxredux-saga

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


Solution

  • You can use regular for...of loop:

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