Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/events.ts>on

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function on
import { on } from "https://deno.land/std@0.61.0/node/events.ts";

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

Parameters

emitter: EventEmitter
event: string | symbol

Returns

AsyncInterable