Interface DomReadonlyEventHost<EventMap>

interface DomReadonlyEventHost<EventMap> {
    hasAnyListeners(): boolean;
    hasListeners(type: {
        [P in string]: Pick<EventMap, keyof EventMap & string>[P] extends Event
            ? P
            : never
    }[keyof EventMap & string]): boolean;
    on<K>(type: K, handler: EventHandler<DomEventMap<EventMap>[K]>, options?: DomEventListenerOptions): Unsubscribe;
}

Type Parameters

  • EventMap

Hierarchy (view full)

Implemented by

Methods

  • 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.