[javascript] Eventsss
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- const EventEmitter = require("events")
- const newEmitter = new EventEmitter()
- newEmitter.on("anevent",()=>{
- console.log("An event is ")
- })
- newEmitter.on("anotherevent",()=>
- {
- console.log("Another event occurred")
- })
- newEmitter.off(("anotherevent"),()=>{
- console.log("Another event stopped")
- })
- //Event handlers are executed in the order of their events emitted
- newEmitter.emit("anotherevent")
- newEmitter.emit("anevent");
Editor
You can edit this paste and save as new: