Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AsyncLoop

An implementation of a loop for asynchronous functions.

Hierarchy

  • AsyncLoop

Index

Constructors

constructor

  • 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

indexSearch playground for index

index: number

Defines the current index of the loop.

iterationsSearch playground for iterations

iterations: number

Defines the number of iterations for the loop

Methods

breakLoopSearch playground for breakLoop

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

    Returns void

executeNextSearch playground for executeNext

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

    Returns void

Static RunSearch playground for Run

  • 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

Static SyncAsyncForLoopSearch playground for SyncAsyncForLoop

  • 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
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method