Class TaskLooper

Run a task in a fixed period loop.

Hierarchy

  • TaskLooper

Constructors

  • Build the looper with a function to invoke on a fixed period loop.

    Parameters

    • fn: (() => Promise<void>)

      the async function to invoke

        • (): Promise<void>
        • Returns Promise<void>

    Returns TaskLooper

Properties

_fn: (() => Promise<void>)

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

_isLooping: boolean
_isStarted: boolean
_periodInMs: number
_timeout: Timeout

Methods

  • Parameters

    • targetFixedPeriod: boolean

    Returns Promise<void>

  • Get the task function to invoke on a fixed period loop.

    Returns (() => Promise<void>)

    the task function

      • (): Promise<void>
      • Returns Promise<void>

  • Indicates if looping.

    Returns boolean

    true if looping, false otherwise

  • Set the loop period in milliseconds.

    Parameters

    • periodInMs: any

      the loop period in milliseconds

    Returns void

  • Start the task loop.

    Parameters

    • periodInMs: number

      the loop period in milliseconds

    • Optional targetFixedPeriod: boolean

      specifies if the task should target a fixed period by accounting for run time (default false)

    Returns void

    this instance for chaining

  • Stop the task loop.

    Returns void

Generated using TypeDoc