JSFiddle - React, Tailwind, and code Playground
by beradrian
JavaScript
class MyCustomEvent extends Event {
x;
constructor(x) {
super("myType");
this.x = x;
}
}
class MyCustomApp extends EventTarget {
#counter = 1;
doIt() {
this.dispatchEvent(new MyCustomEvent(this.#counter++));
}
}
const app = new MyCustomApp();
app.addEventListener("myType", (event) => console.log(event.x));
app.doIt();
app.doIt();