/** * Author: Kevin Nielsen * Copyright Alert Logic Inc, 2019 */ /** * @public * * AlStopwatch is an attempt to encapsulate a few basic timer-related use cases into a simple interface. * Most uses cases can be handled by one of the three static methods: * `Stopwatch.later` - creates a Stopwatch instance that won't be executed until someone calls its `now` or `again` methods. * `Stopwatch.once` - creates a Stopwatch instance that executes once after a specified delay, defaulting to 0. * `Stopwatch.repeatedly` - creates a Stopwatch instance that executes repeatedly at a given interval until its `cancel` method is called. */ export declare class AlStopwatch { callback: { (): void; }; timer: any; interval: number; constructor(callback: { (): void; }); /** * A static method to generate an unscheduled timer */ static later(callback: { (): void; }): AlStopwatch; /** * A static method to generate a timer that will execute once after a given number of milliseconds. */ static once(callback: { (): void; }, delay?: number): AlStopwatch; /** * A static method to generate a timer that will execute intermittently. * Note that this implementation deviates from the behavior of setInterval by *defaulting* * to firing the timer immediately. */ static repeatedly(callback: { (): void; }, interval?: number, beginImmediately?: boolean): AlStopwatch; static promise(interval: number): Promise; /** * The timer's tick handler; executes the callback and, for single-fire timers, clears the timer handle. */ tick: () => void; /** * Cancels a scheduled execution. */ cancel: () => void; /** * Schedules a repeated execution. This method has no effect if there is already a scheduled execution. */ again: (delay?: number) => void; /** * Schedules a repeated execution. This method will cancel any previously scheduled execution. */ reschedule: (delay?: number) => void; /** * Executes the timer immediately (literally, right now!) */ now: () => void; }