Interface NodeEventTarget
addEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): void;
addListener(type: string, listener: (arg: any) => void): this;
dispatchEvent(event: Event): boolean;
emit(type: string, arg: any): boolean;
eventNames(): string[];
getMaxListeners(): number;
listenerCount(type: string): number;
off(
type: string,
listener: (arg: any) => void,
options?: EventListenerOptions,
): this;
on(type: string, listener: (arg: any) => void): this;
once(type: string, listener: (arg: any) => void): this;
removeAllListeners(type?: string): this;
removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: boolean | EventListenerOptions,
): void;
removeListener(
type: string,
listener: (arg: any) => void,
options?: EventListenerOptions,
): this;
setMaxListeners(n: number): void;
}
Hierarchy
- EventTarget
- NodeEventTarget
Methods
addEventListener
- addEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- callback: EventListenerOrEventListenerObject | null
Optionaloptions: boolean | AddEventListenerOptions
Returns void
addListener
Node.js-specific extension to the
EventTargetclass that emulates the equivalentEventEmitterAPI. The only difference betweenaddListener()andaddEventListener()is thataddListener()will return a reference to theEventTarget.Parameters
- type: string
- listener: (arg: any) => void
Returns this
dispatchEvent
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.Parameters
- event: Event
Returns boolean
emit
eventNames
getMaxListeners
listenerCount
off
on
once
removeAllListeners
removeEventListener
- removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Parameters
- type: string
- callback: EventListenerOrEventListenerObject | null
Optionaloptions: boolean | EventListenerOptions
Returns void
removeListener
Node.js-specific extension to the
EventTargetclass that removes thelistenerfor the giventype. The only difference betweenremoveListener()andremoveEventListener()is thatremoveListener()will return a reference to theEventTarget.Parameters
- type: string
- listener: (arg: any) => void
Optionaloptions: EventListenerOptions
Returns this
The
NodeEventTargetis a Node.js-specific extension toEventTargetthat emulates a subset of theEventEmitterAPI.Since
v14.5.0