Skip to main content
Go to Latest
method EventEmitter.prototype.prependOnceListener
import { EventEmitter } from "https://deno.land/std@0.147.0/node/events.ts";

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.

server.prependOnceListener('connection', (stream) => {
  console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

eventName: string | symbol

The name of the event.

listener: (...args: any[]) => void

The callback function