/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ /** * @deprecated Moved to the `@fluidframework/core-utils` package. * @internal */ export interface ITimer { /** * True if timer is currently running */ readonly hasTimer: boolean; /** * Starts the timer */ start(): void; /** * Cancels the timer if already running */ clear(): void; } /** * Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit. * Timeouts may not be exactly accurate due to browser implementations and the OS. * https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate * @param timeoutFn - Executed when the timeout expires * @param timeoutMs - Duration of the timeout in milliseconds * @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when * timeoutMs greater than maxTimeout * @returns The initial timeout * * @deprecated Moved to the `@fluidframework/core-utils` package. * @internal */ export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType) => void): ReturnType; /** * This class is a thin wrapper over setTimeout and clearTimeout which * makes it simpler to keep track of recurring timeouts with the same * or similar handlers and timeouts. This class supports long timeouts * or timeouts exceeding (2^31)-1 ms or approximately 24.8 days. * * @deprecated Moved to the `@fluidframework/core-utils` package. * @internal */ export declare class Timer implements ITimer { private readonly defaultTimeout; private readonly defaultHandler; private readonly getCurrentTick; /** * Returns true if the timer is running. */ get hasTimer(): boolean; private runningState; constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number); /** * Calls setTimeout and tracks the resulting timeout. * @param ms - overrides default timeout in ms * @param handler - overrides default handler */ start(ms?: number, handler?: () => void): void; /** * Calls clearTimeout on the underlying timeout if running. */ clear(): void; /** * Restarts the timer with the new handler and duration. * If a new handler is passed, the original handler may * never execute. * This is a potentially more efficient way to clear and start * a new timer. * @param ms - overrides previous or default timeout in ms * @param handler - overrides previous or default handler */ restart(ms?: number, handler?: () => void): void; private startCore; private handler; private calculateRemainingTime; } /** * @deprecated Moved to the `@fluidframework/core-utils` package. * @internal */ export interface IPromiseTimerResult { timerResult: "timeout" | "cancel"; } /** * Timer which offers a promise that fulfills when the timer * completes. * * @deprecated Moved to the `@fluid-private/client-utils` package. * @internal */ export interface IPromiseTimer extends ITimer { /** * Starts the timer and returns a promise that * resolves when the timer times out or is canceled. */ start(): Promise; } /** * 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. * * @deprecated Moved to the `@fluid-private/client-utils` package. * @internal */ export declare class PromiseTimer implements IPromiseTimer { private deferred?; private readonly timer; /** * {@inheritDoc Timer.hasTimer} */ get hasTimer(): boolean; constructor(defaultTimeout: number, defaultHandler: () => void); /** * {@inheritDoc IPromiseTimer.start} */ start(ms?: number, handler?: () => void): Promise; clear(): void; protected wrapHandler(handler: () => void): void; } //# sourceMappingURL=timer.d.ts.map