Class TypedEventTarget<Events>

This wrapper around EventTarget provides more descriptive type information. By using this class, calls to EventTarget methods are correctly type checked to ensure only allowed event types are used, and that events and their type strings are correctly associated.

For example, when calling TypedEventTarget::addEventListener, the event passed to the callback will have the correct type corresponding to the type of event for which the listener has been added.

Type Parameters

Hierarchy

  • TypedEventTarget

Constructors

Methods

  • Type Parameters

    • K extends string

    Parameters

    • type: K
    • callback: TypedEventListener<EventOfType<K, Events>>
    • Optional options: TypedEventListenerOptions

    Returns void

  • Parameters

    • event: Events

    Returns true

  • Type Parameters

    • K extends string

    Parameters

    • type: K
    • callback: TypedEventListener<EventOfType<K, Events>>

    Returns void

Generated using TypeDoc