PromiseTimer Class

Packages > @fluidframework/common-utils > PromiseTimer

This class is a wrapper over setTimeout and clearTimeout which makes it simpler to keep track of recurring timeouts with the same handlers and timeouts, while also providing a promise that resolves when it times out.

Signature:

export declare class PromiseTimer implements IPromiseTimer 

Implements: IPromiseTimer

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(defaultTimeout, defaultHandler) Constructs a new instance of the PromiseTimer class

Properties

List of properties for this class
Property Modifiers Type Description
hasTimer boolean

Methods

List of methods on this class
Method Modifiers Description
clear()
start(ms, handler)
wrapHandler(handler)

Constructors

PromiseTimer.(constructor)

Constructs a new instance of the PromiseTimer class

Signature:

constructor(defaultTimeout: number, defaultHandler: () => void);

Parameters

List of parameters
Parameter Type Description
defaultTimeout number
defaultHandler () => void

Properties

hasTimer

Signature:

get hasTimer(): boolean;

Methods

clear

Signature:

clear(): void;

Returns:

void

start

Signature:

start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;

Parameters

List of parameters
Parameter Type Description
ms number
handler () => void

Returns:

Promise<IPromiseTimerResult>

wrapHandler

Signature:

protected wrapHandler(handler: () => void): void;

Parameters

List of parameters
Parameter Type Description
handler () => void

Returns:

void