Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/mutevents/mod.ts>EventEmitter

Typed, async, and promiseable events for Deno
Latest
class EventEmitter
import { EventEmitter } from "https://deno.land/x/mutevents@5.4.1/mod.ts";

Methods

private
execute<T, K extends keyof T>(data: T[K], listener?: EventListener<T, K>)
private
executeSync<T, K extends keyof T>(data: T[K], listener?: EventListener<T, K>)
private
listenersOf<K extends keyof T>(type: K, priority?: EventPriority)

Get the listeners of the given event type and priority

emit<K extends keyof T>(type: K, data: T[K]): Promise<EventResult<T, K>>

Asynchronously emits the given data on the given event type

emitSync<K extends keyof T>(type: K, data: T[K]): EventResult<T, K>

Synchronously emits the given data on the given event type

error<K extends keyof T>(unnamed 0: [K, EventPriority])

Promise that rejects (with the result) when the given event type is emitted

on<K extends keyof T>(unnamed 0: [K, EventPriority], ...listeners: EventListener<T, K>[])

Execute the given listeners each time the given event type is emitted

once<K extends keyof T>(unnamed 0: [K, EventPriority], ...listeners: EventListener<T, K>[])

Execute the given listeners once the given event type is emitted (self-cancelling event listener)

reemit<K extends keyof T>(type: K)

Shortcut for creating an event listener that reemits the data on the given event type

reemitSync<K extends keyof T>(type: K)

Shortcut for creating an event listener that synchronously reemits the data on the given event type

wait<K extends keyof T>(unnamed 0: [K, EventPriority])

Abortable promise that resolves (with the result) when the given event type is emitted