Run a task in a fixed period loop.

Hierarchy

  • TaskLooper

Constructors

Properties

Methods

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
_timeout: undefined | Timeout

Methods

  • Parameters

    • periodInMs: number
    • targetFixedPeriod: boolean

    Returns Promise<void>

  • Start the task loop.

    Returns

    this instance for chaining

    Parameters

    • periodInMs: number

      the loop period in milliseconds

    • targetFixedPeriod: boolean

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

    Returns void

Generated using TypeDoc