@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
26 lines (25 loc) • 1.06 kB
TypeScript
import type { AnyToVoidFnSignature } from '../misc/functions';
/**
* Task placeholder with a single place for executing deferred task.
* Only one task can be planed per DelayedTask instance.
* @see put DelayedTask.put behavior description.
*/
export declare class DelayedTask {
protected _fn: AnyToVoidFnSignature | null;
protected _timeout: number | null;
/** Execute deferred task immediately */
protected run: () => void;
/** @returns Function of currently deferred (planned) task */
get fn(): AnyToVoidFnSignature | null;
/**
* Cancel deferred task and planning passed
* @param task - task function
* @param delay - time to delay task execution
* - pass negative or false to execute task immediately
* - pass 0 to plan task to the macrotask
* - pass positive number x to delay task on x ms.
* */
put(task: AnyToVoidFnSignature, delay?: number | string | boolean): AnyToVoidFnSignature | null;
/** Cancel deferred (planned) task */
cancel(): AnyToVoidFnSignature | null;
}