Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

events js

import { EventEmitter } from "node:events";
/**
 * add "type":"module" in package.json
 */

class MyEmitter extends EventEmitter {}

const myEvent = new MyEmitter();

myEvent.on("event", () => {
  console.log("an event occurred!");
});

myEvent.emit("event");
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #events #js
ADD COMMENT
Topic
Name
6+7 =