typed-events-target - v1.0.0
    Preparing search index...

    typed-events-target - v1.0.0

    typed-event-target

    Documentation GitHub NPM Downloads Licence JSR Score CI

    Strongly typed 0-dependency TypeScript EventTarget module.

    Documentation — API Reference

    npm i typed-events-target
    
    import { TypedEvent, TypedEventTarget } from "typed-events-target";
    
    deno add jsr:@von/typed-event-target
    
    import { TypedEvent, TypedEventTarget } from "@von/typed-event-target";
    
    type FooEvent = TypedEvent<"foo", string>;
    type BarEvent = TypedEvent<"bar", number>;

    class ExampleTarget extends TypedEventTarget<FooEvent | BarEvent> {
    public emit(): void {
    this.dispatchEvent("foo", "value");
    this.dispatchEvent("bar", 42);
    }
    }

    const target = new ExampleTarget();

    target.addEventListener("foo", (evt) => console.log(evt.detail));
    target.addEventListener("bar", (evt) => console.log(evt.detail));

    target.emit();

    Copyright © 2026 Violation.

    This project is licensed under the terms of the GPL-3.0 licence.