@bodil/dom
    Preparing search index...

    Class EmitterElement

    A subclass of HTMLElement which declares what events can be emitted by it at the type level. Thus, calling this.emit() with an undeclared event name will be a type error.

    It also offers proper type checking of the data provided to EmitterElement.emit using the types declared in HTMLElementEventMap.

    declare global {
    interface HTMLElementEventMap {
    "my-event": { name: string; count: number; }
    }
    }

    class MyElement extends EmitterElement {
    emits!: Emits<"my-event">;

    handleMyEvent() {
    this.emit("my-event", { name: "Joe", count: 1337 });
    }
    }

    Hierarchy (View Summary)

    Events

    emits: {}

    Declares the events this element can emit.

    class MyElement extends EmitterElement {
    emits!: Emits<"my-event" | "my-other-event";
    }

    Other

    • Returns EmitterElement