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
Constructor | Modifiers | Description |
---|---|---|
(constructor)(defaultTimeout, defaultHandler) | Constructs a new instance of the PromiseTimer class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
hasTimer | boolean |
Methods
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
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
Parameter | Type | Description |
---|---|---|
ms | number | |
handler | () => void |
Returns:
Promise<IPromiseTimerResult>
wrapHandler
Signature:
protected wrapHandler(handler: () => void): void;
Parameters
Parameter | Type | Description |
---|---|---|
handler | () => void |
Returns:
void