Skip to main content
Go to Latest
method EventEmitter.prototype.once
import { EventEmitter } from "https://deno.land/x/evtemitter@v3.0.0/EventEmitter.ts";

add a callback to an event only once. After that, the listener is removed.

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 only once. After that, the listener is removed.

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"]