Class AsyncLoop

Description

Async loop implementation

Example

import { AsyncLoop } from '@biorate/async-loop';

(async () => {
let i = 0;
const loop = new AsyncLoop(
() => {
console.log(++i); // 1, 2, 3 ... e.t.c
},
console.error,
1000,
);
})();

Hierarchy

  • AsyncLoop

Constructors

  • Parameters

    • process: (() => void | Promise<void>)
        • (): void | Promise<void>
        • Returns void | Promise<void>

    • Optional error: ((...e) => void | Promise<void>)
      Optional
        • (...e): void | Promise<void>
        • Parameters

          • Rest ...e: any[]
            Rest

          Returns void | Promise<void>

    • interval: number = 1000

    Returns AsyncLoop

Properties

#error: ((e) => void | Promise<void>)

Type declaration

    • (e): void | Promise<void>
    • Parameters

      • e: unknown

      Returns void | Promise<void>

#interval: number
#paused: boolean = false
#process: (() => void | Promise<void>)

Type declaration

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

#stoped: boolean = false

Methods

Generated using TypeDoc