Last active
June 9, 2022 05:23
-
-
Save mvneerven/0c9b98f60a4869691f616c76e7f9a99f to your computer and use it in GitHub Desktop.
Using Events class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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