Package-level declarations

Types

Link copied to clipboard
open external class EventEmitter

The EventEmitter class is defined and exposed by the node:events module:

Link copied to clipboard

Integrates EventEmitter with AsyncResource for EventEmitters that require manual async tracking. Specifically, all events emitted by instances of events.EventEmitterAsyncResource will run within its async context.

Link copied to clipboard
sealed external interface EventEmitterOptions
Link copied to clipboard
Link copied to clipboard
external interface EventType<in T : EventEmitter, out P : JsTuple>
Link copied to clipboard
external interface LegacyEventType
Link copied to clipboard
sealed external interface StaticEventEmitterOptions

Functions

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.addListener(type: EventType<T, P>, listener: (P) -> Unit)

Alias for emitter.on(eventName, listener).

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.emit(type: EventType<T, P>, payload: P): Boolean

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Link copied to clipboard
inline fun <T : EventEmitter, P : JsTuple> EventType(value: Symbol): EventType<T, P>
inline fun <T : EventEmitter, P : JsTuple> EventType(value: String): EventType<T, P>
Link copied to clipboard
Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.listenerCount(type: EventType<T, P>, listener: (P) -> Unit = undefined.unsafeCast<Nothing>()): Double

Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName.

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.off(type: EventType<T, P>, listener: (P) -> Unit)

Alias for emitter.removeListener().

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.on(type: EventType<T, P>, listener: (P) -> Unit)

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.once(type: EventType<T, P>, listener: (P) -> Unit)

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.prependListener(type: EventType<T, P>, listener: (P) -> Unit)

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.prependOnceListener(type: EventType<T, P>, listener: (P) -> Unit)

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

Link copied to clipboard
fun <T : EventEmitter> T.removeAllListeners(type: EventType<T, *> = undefined.unsafeCast<Nothing>())

Removes all listeners, or those of the specified eventName.

Link copied to clipboard
fun <T : EventEmitter, P : JsTuple> T.removeListener(type: EventType<T, P>, listener: (P) -> Unit)

Removes the specified listener from the listener array for the event named eventName.