Function event

  • Subscribes to an event, emitting data

    Type Parameters

    • TEventArgs extends Record<string, any>

    Parameters

    • targetOrQuery: null | string | EventTarget

      Event emitter, HTML element or string. If a string, it will be queryed as a selector.

    • name: string

      Event name

    • initialValue: undefined | TEventArgs
    • options: Partial<EventOptions> = {}

      Options

    Returns ReactiveInitial<TEventArgs> & Reactive<TEventArgs>

    const r = Rx.From.event(document, `pointermove`);
    r.onValue(event => {
    const { x, y } = event;
    });

    If options.lazy is true (default: false), event will only be subscribed to when the stream itself has a subscriber.

    options.debugFiring and options.debugLifecycle can be turned on to troubleshoot behaviour of the stream if necessary.