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.

Revisions

  1. mvneerven revised this gist Jun 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion myclass.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ import { Events } from "./events";

    export class MyClass {

    events = new Events(this);
    events = new Events(this); // there we go!

    constructor(data) {
    await init();
  2. mvneerven revised this gist Jun 2, 2022. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions myclass.js
    Original file line number Diff line number Diff line change
    @@ -15,5 +15,13 @@ export class MyClass {
    // omitted
    }
    });

    /* or....
    this.dispatchEvent(new CustomEvent("ready", {
    detail: {
    // omitted
    }
    }));
    */
    }
    }
  3. mvneerven created this gist Jun 2, 2022.
    19 changes: 19 additions & 0 deletions myclass.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import { Events } from "./events";

    export class MyClass {

    events = new Events(this);

    constructor(data) {
    await init();
    }

    async init() {
    // omitted code
    this.emit("ready", {
    detail: {
    // omitted
    }
    });
    }
    }