Class TypedEventTarget<TEvents>

Decorator for EventTarget allowing to strongly type events and listeners

Type Parameters

  • TEvents extends TypedEvent<any>

    union of dispatched events

Hierarchy (View Summary)

Constructors

Methods

  • Type Parameters

    • T extends string

      the name of event

    • E extends TypedEvent<any> & { type: T }

      the class of the event

    Parameters

    • type: T
    • callback: EventListenerObject | (e: E) => void
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    Returns boolean

  • Type Parameters

    • T extends string

      the name of event

    • E extends TypedEvent<any> & { type: T }

      the class of the event

    Parameters

    • type: TEvents["type"]
    • callback: EventListenerObject | (e: E) => void
    • Optionaloptions: boolean | EventListenerOptions

    Returns void