Function to be called with counter as a first parameter and token as a second parameter starting from second parameter of this function. Returns true when all operations are complete or false when new loop is needed.
Optional token: AsyncLoopTokenOptional valFrom: numberStarting counter value
Optional token: AsyncLoopTokenToken. An object with cancel property to cancel loop
Optional finishedCallback: ((idx, token?) => void)Function to be called when all operations are done (main function from first parameter returns true) with parameters - counter, token.
Optional token: AsyncLoopTokenasyncLoop( function(i) {
if (i >= arr.length)
return false;
else {
arr[i].processIt;
}
});
asyncLoop
Call function repeatedly while not fully blocking the main JS thread. It's useful for execution of loops that can take some time process and we don't want to block the main thread completely (and don't want to start a new thread either).