@studiokeywi/banjo - v0.0.1
    Preparing search index...

    Interface Emitter<Events, Available>

    A wrapper for the EventTarget interface that provides the ability to provide known event name/types

    interface Emitter<
        Events extends EventsMap,
        Available extends AvailableEvents<Events> = AvailableEvents<Events>,
    > {
        emit(event: Available[keyof Available]): this;
        off<const Type extends string>(
            type: Type,
            handler: (event: Available[Type]) => void | Promise<void>,
        ): this;
        on<const Type extends string>(
            type: Type,
            handler: (event: Available[Type]) => void | Promise<void>,
        ): this;
        once<const Type extends string>(
            type: Type,
            handler: (event: Available[Type]) => void | Promise<void>,
        ): this;
        set(
            handlers: Partial<
                {
                    [Key in string
                    | number
                    | symbol]: (event: Available[Key]) => void | Promise<void>
                },
            >,
        ): this;
    }

    Type Parameters

    Index

    Methods

    Methods

    • Add a new event listener for the given event type

      Type Parameters

      • const Type extends string

      Parameters

      Returns this

    • Add a new event listener for the given event type

      Type Parameters

      • const Type extends string

      Parameters

      Returns this

    • Add a new event listener for the given event type that only executes once

      Type Parameters

      • const Type extends string

      Parameters

      Returns this

    • Set multiple event listeners at once through a single object

      Parameters

      • handlers: Partial<
            {
                [Key in string
                | number
                | symbol]: (event: Available[Key]) => void | Promise<void>
            },
        >

      Returns this