UNPKG

1.72 kBTypeScriptView Raw
1import { FederatedEvent } from './FederatedEvent';
2import type { IEventTarget } from './interfaces';
3export declare const DELEGATION_SPLITTER = ":";
4/**
5 * Objects that can receive events and may have listeners for them.
6 * eg. Element, Canvas, DisplayObject
7 * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
8 */
9export declare class EventTarget implements IEventTarget {
10 /**
11 * event emitter
12 */
13 emitter: import("eventemitter3")<string | symbol, any>;
14 /**
15 * @deprecated
16 * @alias addEventListener
17 */
18 on(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
19 /**
20 * support `capture` & `once` in options
21 * @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
22 */
23 addEventListener(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
24 /**
25 * @deprecated
26 * @alias removeEventListener
27 */
28 off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
29 removeAllEventListeners(): void;
30 removeEventListener(type: string, listener?: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
31 /**
32 * @deprecated
33 * @alias dispatchEvent
34 */
35 emit(eventName: string, object: object): void;
36 /**
37 * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
38 */
39 dispatchEvent<T extends FederatedEvent>(e: T): boolean;
40}
41
\No newline at end of file