Library API
    Preparing search index...

    Class Reactive<T>

    Universal, zero-dependency async reactive stream combining push-based event emission and pull-based AsyncIterable iteration with native TC39 resource management (using / await using) and Garbage Collection finalization safety.

    const stream = new Reactive<number>();

    // Consumer 1: Pull-mode
    queueMicrotask(async () => {
    const val = await stream.pull(); // 42
    });

    // Producer: Push-mode
    stream.push(42);

    Type Parameters

    • T

    Implements

    • AsyncIterable<T>
    • AsyncIterator<T, void, unknown>
    • Disposable
    • AsyncDisposable
    Index
    isReactive: ReactiveTypeGuard

    Type guard to check if a value is an authentic Reactive stream instance

    • Broadcasts a value to ALL pending pull waiters and push listeners simultaneously.

      Parameters

      • value: T

        The value to broadcast

      Returns boolean

      True if the value was successfully emitted; false if completed or inactive

      cast

    • Casts a value to ALL pending pull waiters and push listeners simultaneously (multicast fan-out).

      Parameters

      • value: T

        The value to cast across all consumers

      Returns boolean

      True if the value was successfully emitted; false if completed or inactive

    • Emits a value to active pull-mode consumers or push-mode listeners.

      Parameters

      • value: T

        The value to emit

      Returns boolean

      True if the value was successfully emitted; false if completed or inactive

      push

    • Subscribes to stream events with optional AbortSignal and once configuration. Returns a disposable Subscription handle for explicit resource management (using sub = ...).

      Parameters

      • event: "data"

        'data', 'error', 'end', or 'stop'

      • listener: Listener<T>

        Callback to invoke when the event fires

      • Optionaloptions: SubscriptionOptions

        Subscription options (AbortSignal, once)

      Returns ReactiveSubscription

      A disposable Subscription handle

    • Subscribes to stream events with optional AbortSignal and once configuration. Returns a disposable Subscription handle for explicit resource management (using sub = ...).

      Parameters

      • event: "error"

        'data', 'error', 'end', or 'stop'

      • listener: ErrorListener

        Callback to invoke when the event fires

      • Optionaloptions: SubscriptionOptions

        Subscription options (AbortSignal, once)

      Returns ReactiveSubscription

      A disposable Subscription handle

    • Subscribes to stream events with optional AbortSignal and once configuration. Returns a disposable Subscription handle for explicit resource management (using sub = ...).

      Parameters

      • event: "end" | "stop"

        'data', 'error', 'end', or 'stop'

      • listener: EndListener

        Callback to invoke when the event fires

      • Optionaloptions: SubscriptionOptions

        Subscription options (AbortSignal, once)

      Returns ReactiveSubscription

      A disposable Subscription handle

    • Pushes data into the stream (producer mode) or registers a listener (consumer mode).

      Parameters

      • value: T

      Returns boolean

      True if the value was successfully emitted; false if completed or inactive; Reactive.Subscription if registering a listener

    • Pushes data into the stream (producer mode) or registers a listener (consumer mode).

      Parameters

      Returns ReactiveSubscription

      True if the value was successfully emitted; false if completed or inactive; Reactive.Subscription if registering a listener

    • Throws an error into the stream, rejecting pending waiters and stopping the stream.

      Parameters

      • Optionalerr: any

      Returns Promise<IteratorResult<T, void>>

    • Returns a new Reactive stream that mirrors the source but completes automatically when the given notifier (AbortSignal, Promise, or trigger Reactive stream) fires.

      Parameters

      • notifier: Promise<any> | AbortSignal | Reactive<any>

        An AbortSignal, Promise, or Reactive stream bounding this stream's lifecycle.

      Returns Reactive<T>

      A new Reactive stream

    • Creates a Reactive stream from an iterable, async iterable, Promise, or Signal.

      Type Parameters

      • V

      Parameters

      • source:
            | Iterable<V, any, any>
            | AsyncIterable<V, any, any>
            | Promise<V>
            | { get(): V }
            | (() => V)

        The source collection, promise, or reactive signal

      • Optionaloptions: Options<V>

        Optional configuration options

      Returns Reactive<V>

      A Reactive stream instance

    • Bridges a Signify or Signal node into a Reactive async stream. Automatically pushes updates to the stream whenever the signal changes.

      Type Parameters

      • V

      Parameters

      • source: { get(): V } | (() => V)

        The signal or getter function to stream

      • Optionaloptions: Options<V>

        Optional configuration options

      Returns Reactive<V>

      A Reactive stream instance