Interface ObservableLike<T>

The base interface for observable objects.

interface ObservableLike<T = unknown> {
    "[observable]"(): ObservableLike<T>;
    "@@observable"(): ObservableLike<T>;
    subscribe(observer: Observer<T>): Subscription;
    subscribe(
        onNext: (value: T) => void,
        onError?: (error: Error) => void,
        onComplete?: () => void,
    ): Subscription;
    subscribe(
        ...args:
            | [Observer<T>]
            | [(value: T) => void, (error: Error) => void?, () => void?],
    ): Subscription;
}

Type Parameters

  • T = unknown

Hierarchy (View Summary)

Implemented by

Methods

  • Subscribes the given observer to this object.

    Parameters

    • observer: Observer<T>

      The observer to subscribe.

    Returns Subscription

    Object which can be used to unsubscribe the observer.

  • Constructs a new observer using the given callback functions and subscribes it to this object.

    Parameters

    • onNext: (value: T) => void

      Receives the next value in the sequence.

    • OptionalonError: (error: Error) => void

      Receives the sequence error.

    • OptionalonComplete: () => void

      Receives a completion notification.

    Returns Subscription

    Object which can be used to unsubscribe the observer.

  • Parameters

    • ...args: [Observer<T>] | [(value: T) => void, (error: Error) => void?, () => void?]

    Returns Subscription