Options
All
  • Public
  • Public/Protected
  • All
Menu

An implementation of a loop for asynchronous functions.

Hierarchy

  • AsyncLoop

Index

Constructors

  • new AsyncLoop(iterations: number, func: ((asyncLoop: AsyncLoop) => void), successCallback: (() => void), offset?: number): AsyncLoop
  • Constructor.

    Parameters

    • iterations: number

      the number of iterations.

    • func: ((asyncLoop: AsyncLoop) => void)

      the function to run each iteration

    • successCallback: (() => void)

      the callback that will be called upon successful execution

        • (): void
        • Returns void

    • Optional offset: number

      starting offset.

    Returns AsyncLoop

Properties

index: number

Defines the current index of the loop.

iterations: number

Defines the number of iterations for the loop

Methods

  • breakLoop(): void
  • Break the loop and run the success callback.

    Returns void

  • executeNext(): void
  • Execute the next iteration. Must be called after the last iteration was finished.

    Returns void

  • Run(iterations: number, fn: ((asyncLoop: AsyncLoop) => void), successCallback: (() => void), offset?: number): AsyncLoop
  • Create 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

        • (): void
        • Returns void

    • Optional offset: number

      starting offset.

    Returns AsyncLoop

    the created async loop object

  • SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: ((iteration: number) => void), callback: (() => void), breakFunction?: (() => boolean), timeout?: number): AsyncLoop
  • A 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.

        • (iteration: number): void
        • Parameters

          • iteration: number

          Returns void

    • callback: (() => void)

      a success call back that will be called when iterating stops.

        • (): void
        • Returns void

    • Optional breakFunction: (() => boolean)

      a break condition (optional)

        • (): boolean
        • Returns boolean

    • Optional timeout: number

      timeout settings for the setTimeout function. default - 0.

    Returns AsyncLoop

    the created async loop object

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Static method

Settings

Theme