Skip to main content

Class: TimerManager

Defined in: TimerManager.ts:4

Manages timers so that this application can be cleanly exited

Extends​

  • any

Constructors​

Constructor​

new TimerManager(): TimerManager

Returns​

TimerManager

Inherited from​

null.constructor

Properties​

storedIntervals​

private static storedIntervals: Set<Timeout>

Defined in: TimerManager.ts:13

A set of intervals to clear on destroy


storedTimeouts​

private static storedTimeouts: Set<Timeout>

Defined in: TimerManager.ts:8

A set of timeouts to clear on destroy

Methods​

clearInterval()​

static clearInterval(interval: Timeout): void

Defined in: TimerManager.ts:55

Clears an internal created through this class

Parameters​

ParameterTypeDescription
intervalTimeoutThe interval to clear

Returns​

void


clearTimeout()​

static clearTimeout(timeout: Timeout): void

Defined in: TimerManager.ts:34

Clears a timeout created through this class

Parameters​

ParameterTypeDescription
timeoutTimeoutThe timeout to clear

Returns​

void


destroy()​

static destroy(): void

Defined in: TimerManager.ts:63

Clears running timeouts and intervals created through this class so NodeJS can gracefully exit

Returns​

void


setInterval()​

static setInterval<A>(fn: (...args: A[]) => void, delay: number, ...args: A[]): Timeout

Defined in: TimerManager.ts:45

Creates an interval gets cleared when destroyed

Type Parameters​

Type ParameterDefault type
Aunknown

Parameters​

ParameterTypeDescription
fn(...args: A[]) => voidcallback function
delaynumberamount of time before running the callback
...argsA[]additional arguments to pass back to the callback

Returns​

Timeout


setTimeout()​

static setTimeout<A>(fn: (...args: A[]) => void, delay: number, ...args: A[]): Timeout

Defined in: TimerManager.ts:21

Creates a timeout gets cleared when destroyed

Type Parameters​

Type ParameterDefault type
Aunknown

Parameters​

ParameterTypeDescription
fn(...args: A[]) => voidcallback function
delaynumberamount of time before running the callback
...argsA[]additional arguments to pass back to the callback

Returns​

Timeout