• Create an event source from an element, window, or other event target

    You can manually override the expected event type using a type parameter, e.g. fromDomEvent<CustomEvent>(someTarget, "custom-event").

    Type Parameters

    • T extends HTMLElement
    • K extends keyof HTMLElementEventMap

    Parameters

    • target: T

      an HTMLElement, Window, Document, or other EventTarget.

    • type: K

      the name of the event to add a listener for

    • Optional options: boolean | AddEventListenerOptions

      a boolean capture option, or an object of event listener options

    Returns Source<HTMLElementEventMap[K]>

    a source that can be subscribed or piped, issuing events from the target of the specified type.

  • Type Parameters

    • T extends Window
    • K extends keyof WindowEventMap

    Parameters

    • target: T
    • type: K
    • Optional options: boolean | AddEventListenerOptions

    Returns Source<WindowEventMap[K]>

  • Type Parameters

    • T extends Document
    • K extends keyof DocumentEventMap

    Parameters

    • target: T
    • type: K
    • Optional options: boolean | AddEventListenerOptions

    Returns Source<DocumentEventMap[K]>

  • Type Parameters

    • T extends Event

    Parameters

    • target: EventTarget
    • type: string
    • Optional options: boolean | AddEventListenerOptions

    Returns Source<T>