Skip to content

Instantly share code, notes, and snippets.

@mvneerven
Last active June 9, 2022 05:23
Show Gist options
  • Select an option

  • Save mvneerven/0c9b98f60a4869691f616c76e7f9a99f to your computer and use it in GitHub Desktop.

Select an option

Save mvneerven/0c9b98f60a4869691f616c76e7f9a99f to your computer and use it in GitHub Desktop.
Using Events class
import { Events } from "./events";
export class MyClass {
events = new Events(this); // there we go!
constructor(data) {
await init();
}
async init() {
// omitted code
this.emit("ready", {
detail: {
// omitted
}
});
/* or....
this.dispatchEvent(new CustomEvent("ready", {
detail: {
// omitted
}
}));
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment