Class DomEventHost<EventMap>

Wraps an EventTarget with a ReadonlyEventHost interface.

Type Parameters

  • EventMap

Hierarchy (view full)

Implements

Constructors

Properties

eventTarget: EventTarget

Methods

  • Disposal of a DomEventHost removes all listeners.

    Returns void

  • Returns true if the event host has any listeners.

    Returns boolean

  • Returns true if the event host has any listeners for the given type.

    Parameters

    • type: {
          [P in string]: Pick<EventMap, keyof EventMap & string>[P] extends Event
              ? P
              : never
      }[keyof EventMap & string]

    Returns boolean

  • Adds an event handler for the given typed event.

    Type Parameters

    • K extends string

    Parameters

    • type: K

      A case-sensitive string representing the event type to listen for.

    • handler: EventHandler<DomEventMap<EventMap>[K]>

      A callback to invoke when the event with the given type is dispatched.

    • Optionaloptions: DomEventListenerOptions

      An options object specifies characteristics about the event listener.

    Returns Unsubscribe

    Returns a method, when invoked, removes the handler.