Class AsyncLoop
Properties
index
Defines the current index of the loop.
iterations
Defines the number of iterations for the loop
Methods
break Loop
-
Break the loop and run the success callback.
Returns void
execute Next
-
Execute the next iteration. Must be called after the last iteration was finished.
Returns void
StaticRun
-
Run(
iterations: number,
fn: (asyncLoop: AsyncLoop) => void,
successCallback: () => void,
offset?: number,
): AsyncLoopCreate and run an async loop.
Parameters
- iterations: number
the number of iterations.
- fn: (asyncLoop: AsyncLoop) => void
the function to run each iteration
- successCallback: () => void
the callback that will be called upon successful execution
- offset: number = 0
starting offset.
Returns AsyncLoop
the created async loop object
- iterations: number
StaticSync Async For Loop
-
SyncAsyncForLoop(
iterations: number,
syncedIterations: number,
fn: (iteration: number) => void,
callback: () => void,
breakFunction?: () => boolean,
timeout?: number,
): AsyncLoopA for-loop that will run a given number of iterations synchronous and the rest async.
Parameters
- iterations: number
total number of iterations
- syncedIterations: number
number of synchronous iterations in each async iteration.
- fn: (iteration: number) => void
the function to call each iteration.
- callback: () => void
a success call back that will be called when iterating stops.
OptionalbreakFunction: () => booleana break condition (optional)
- timeout: number = 0
timeout settings for the setTimeout function. default - 0.
Returns AsyncLoop
the created async loop object
- iterations: number
An implementation of a loop for asynchronous functions.