NodeEventTarget

external interface NodeEventTarget : EventTarget(source)

The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API.

Since

v14.5.0

Functions

Link copied to clipboard
abstract external fun addListener(type: String, listener: (arg: Any?) -> Unit)

Node.js-specific extension to the EventTarget class that emulates the equivalent EventEmitter API. The only difference between addListener() and addEventListener() is that addListener() will return a reference to the EventTarget.

Link copied to clipboard
open external fun dispatchEvent(event: Event): Boolean
Link copied to clipboard
abstract external fun emit(type: String, arg: Any?): Boolean

Node.js-specific extension to the EventTarget class that dispatches the arg to the list of handlers for type.

Link copied to clipboard
abstract external fun eventNames(): ReadonlyArray<String>

Node.js-specific extension to the EventTarget class that returns an array of event type names for which event listeners are registered.

Link copied to clipboard
abstract external fun getMaxListeners(): Double

Node.js-specific extension to the EventTarget class that returns the number of max event listeners.

Link copied to clipboard
abstract external fun listenerCount(type: String): Double

Node.js-specific extension to the EventTarget class that returns the number of event listeners registered for the type.

Link copied to clipboard
abstract external fun off(type: String, listener: (arg: Any?) -> Unit, options: EventListenerOptions = definedExternally)

Node.js-specific alias for eventTarget.removeEventListener().

Link copied to clipboard
abstract external fun on(type: String, listener: (arg: Any?) -> Unit)

Node.js-specific alias for eventTarget.addEventListener().

Link copied to clipboard
abstract external fun once(type: String, listener: (arg: Any?) -> Unit)

Node.js-specific extension to the EventTarget class that adds a once listener for the given event type. This is equivalent to calling on with the once option set to true.

Link copied to clipboard
abstract external fun removeAllListeners(type: String = definedExternally)

Node.js-specific extension to the EventTarget class. If type is specified, removes all registered listeners for type, otherwise removes all registered listeners.

Link copied to clipboard
abstract external fun removeListener(type: String, listener: (arg: Any?) -> Unit, options: EventListenerOptions = definedExternally)

Node.js-specific extension to the EventTarget class that removes the listener for the given type. The only difference between removeListener() and removeEventListener() is that removeListener() will return a reference to the EventTarget.

Link copied to clipboard
abstract external fun setMaxListeners(n: Number)

Node.js-specific extension to the EventTarget class that sets the number of max event listeners as n.

Link copied to clipboard
external fun <T : Event> when(type: EventType<T>, options: ObservableEventListenerOptions?): Observable<T>