UNPKG

@exadel/esl

Version:

Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components

19 lines (18 loc) 1.12 kB
/** Interface to describe abstract listenable target */ export type ListenableTarget = { addEventListener: (event: string, callback: (payload: any) => void, options?: boolean | AddEventListenerOptions | undefined) => void; removeEventListener: (event: string, callback: (payload: any) => void, options?: boolean | AddEventListenerOptions | undefined) => void; }; /** * @returns Promise that will be resolved by dispatching `event` on `target` * Or it will be rejected in `timeout` if it's specified * Optional `options` for addEventListener can be also specified */ export declare function promisifyEvent(target: ListenableTarget, event: string, timeout?: number | null | undefined, options?: boolean | AddEventListenerOptions): Promise<Event>; /** * Short helper to make Promise from element state marker * @returns Promise that will be resolved if the target `marker` property is truthful or `event` is dispatched * @example * `const imgReady = promisifyMarker(eslImage, 'ready');` */ export declare function promisifyMarker(target: HTMLElement, marker: string, event?: string): Promise<HTMLElement>;