import { type Reference } from "@knyt/artisan"; import type { BasicEvent } from "./BasicEvent.ts"; import type { SyncEventListener } from "./types.ts"; /** * @public */ export type PropertyChangePayload

= { currentValue: T; previousValue: T; propertyName: P; }; /** * @public */ export type PropertyChangeHandler

= (args: PropertyChangePayload) => void; /** * @public */ export type InferPropertyChangePayload = PropertyChangePayload; /** * @public */ export type InferPropertyChangeHandler = PropertyChangeHandler; /** * An event emitter that facilitates dispatching events asynchronously. * * @remarks * * This class partially implements the interface of native event emitters * to dispatch events on both a given event emitter, which is typically a DOM element, * and an internal event station asynchronously. * * The goal is to provide a way to dispatch native-like events asynchronously in a similar manner * to the native interfaces facilitating better interoperability. */ export declare class BasicEmitter implements BasicEvent.Emitter { #private; /** * @param pairedDispatcher - Another event emitter or a target element to dispatch events on. */ constructor(pairedDispatcher: BasicEmitter.Input); /** * Dispatch the event on the target element and the event station. * * If the target element is not set, the event will only be dispatched on the event station. * * @remarks * * The event should be defined on `HTMLElementEventMap`. * * ```ts * define global { * interface HTMLElementEventMap { * "custom-event": CustomEvent; * } * } * ``` * * @see HTMLElementEventMap */ dispatchEvent(customEvent: T): Promise; /** * Add an event listener to the emitter. * * TODO: Add support for `options.async` to add the listener to the event station. */ addEventListener(type: K, listener: SyncEventListener, options?: boolean | AddEventListenerOptions): void; /** * Remove an event listener to the emitter. * * TODO: Add support for `options.async` to remove the listener to the event station. */ removeEventListener(type: K, listener: SyncEventListener, _options?: boolean | EventListenerOptions): void; replaceEventListener(type: K, listenerPair: readonly [ prevListener: SyncEventListener | undefined, nextListener: SyncEventListener | undefined ], options?: boolean | AddEventListenerOptions): void; /** * Creates a property change handler that replaces the event listener for the associated DOM event. * * @remarks * * This can be used as a standalone function. * * @deprecated */ createEventListenerPropertyChangeHandler: (domEventNameByPropertyName: Partial>) => InferPropertyChangeHandler; } export declare namespace BasicEmitter { type Input = null | Reference.Maybe; } //# sourceMappingURL=BasicEmitter.d.ts.map