Skip to main content
Module

x/evtemitter/mod.ts>EventEmitter#on

Eventemitter for deno.
Go to Latest
method EventEmitter.prototype.on
import { EventEmitter } from "https://deno.land/x/evtemitter@v3.0.0/mod.ts";

add a callback to an event

Type Parameters

Ev extends ReservedOrUserEventNames<ReservedEvents, UserEvents>

Parameters

type: Ev

the event name the callback should listen to

callback: ReservedOrUserListenerOn<ReservedEvents, UserEvents, Ev>

the callback to execute when the event is dispatched

optional
options: boolean | AddEventListenerOptions

event options EventTarget["addEventListener"]

add a callback to multiple events

Type Parameters

Ev extends ReservedOrUserEventNames<ReservedEvents, UserEvents>

Parameters

types: Ev[]

an array of the event names the callback should listen to

callback: ReservedOrUserListenerOn<ReservedEvents, UserEvents, Ev>

the callback to execute when the event is dispatched

optional
options: boolean | AddEventListenerOptions

event options EventTarget["addEventListener"]