///
import EventEmitter from 'eventemitter3';
declare type DelayCallback = () => void;
declare type DelayCallID = string | number | symbol;
declare type DelayCallTimeoutID = number | NodeJS.Timeout;
declare type DelayCallQueue = Map;
interface DelayCallQueueItem {
done: symbol;
cancel: symbol;
timeoutID: DelayCallTimeoutID;
}
declare class DelayCallQueueManager extends EventEmitter {
protected __getQueueItem(queue: DelayCallQueue, id: DelayCallID): DelayCallQueueItem;
protected __setTimeout(callback: DelayCallback, delay: number): DelayCallTimeoutID;
protected __clearTimeout(item: DelayCallQueueItem): void;
protected __waitCall(queue: DelayCallQueue, id: DelayCallID): Promise;
protected __request(queue: DelayCallQueue, id: DelayCallID, callback: DelayCallback, delay: number): void;
protected __cancel(queue: DelayCallQueue, id: DelayCallID): boolean;
protected __cancelAll(queue: DelayCallQueue): void;
protected __done(queue: DelayCallQueue, id: DelayCallID): Promise;
}
export declare class DelayCall extends DelayCallQueueManager {
protected readonly __delay: number;
protected readonly __queue: DelayCallQueue;
/**
* @param globalDelay Ignore requests with the same unique name if repeated during this time. You can also set each as a `delay` parameter for the `request` method. The default value of the `delay` is `25`
*/
constructor(globalDelay?: number);
/**
* Request to execute the callback function. The function is not called immediately and waits as much as the `delay` parameter. The default value of the `delay` is `this.__delay`.
* @param id It's a unique name for the task. If this value is called in duplicate, the existing task is ignored.
* @param callback The callback function to be called.
* @param delay Ignore requests with the same unique name if repeated during this time.
* @returns This instance.
*/
request(id: DelayCallID, callback: DelayCallback, delay?: number): this;
/**
* Cancel the requested task with the `id` parameter.
* @param id It's a unique name for the task.
* @returns If there was a scheduled task, return `true`, otherwise `false`.
*/
cancel(id: DelayCallID): boolean;
/**
* Cancel all requested tasks.
*/
cancelAll(): void;
/**
* Wait until the requested task of the `id` parameter is actually called. If canceled by `cancel` method, emit error.
* @param id It's a unique name for the task.
* @returns The Promise instance.
*/
done(id: DelayCallID): Promise;
/**
* Call before destroying an instance.
*/
destroy(): void;
}
export declare class DelayCallGlobally extends DelayCallQueueManager {
protected static __Delay: number;
protected static __Queue: DelayCallQueue;
/**
* @param globalDelay Ignore requests with the same unique name if repeated during this time. You can also set each as a `delay` parameter for the `request` method. The default value of the `delay` is `25`
*/
constructor(globalDelay?: number);
/**
* Request to execute the callback function. The function is not called immediately and waits as much as the `delay` parameter. The default value of the `delay` is `this.__delay`.
* @param id It's a unique name for the task. If this value is called in duplicate, the existing task is ignored.
* @param callback The callback function to be called.
* @param delay Ignore requests with the same unique name if repeated during this time.
* @returns This instance.
*/
request(id: DelayCallID, callback: DelayCallback, delay?: number): this;
/**
* Cancel the requested task with the `id` parameter.
* @param id It's a unique name for the task.
* @returns If there was a scheduled task, return `true`, otherwise `false`.
*/
cancel(id: DelayCallID): boolean;
/**
* Cancel all requested tasks.
*/
cancelAll(): void;
/**
* Wait until the requested task of the `id` parameter is actually called.
* @param id It's a unique name for the task.
* @returns The Promise instance.
*/
done(id: DelayCallID): Promise;
/**
* Call before destroying an app.
*/
destroy(): void;
}
export {};