CLASSES
TagsA - Z

AsyncLoop

Description

class AsyncLoop

An implementation of a loop for asynchronous functions.

Constructor

new AsyncLoop(iterations, _fn, _successCallback, offset)

Constroctor.

Parameters

Name Type Description
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 succesful execution

Members

iterations : number

index : number

Methods

executeNext() void

Execute the next iteration. Must be called after the last iteration was finished.

breakLoop() void

Break the loop and run the success callback.

static Run(iterations, _fn, _successCallback, offset) AsyncLoop

Helper function

Parameters

Name Type Description
iterations number
_fn (asyncLoop: AsyncLoop) => void
_successCallback () => void

static SyncAsyncForLoop(iterations, syncedIterations, fn, callback, breakFunction, timeout) void

A for-loop that will run a given number of iterations synchronous and the rest async.

@constructor

Parameters

Name Type Description
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.
optional breakFunction () => boolean a break condition (optional)