Represents a subject that can emit data and be subscribed to.

Type Parameters

  • Data = any

    The type of data that the subject emits.

Hierarchy (View Summary)

Implements

Observables

operator: <T = any>(
    callbackfn: (value: TObserver<Data>) => TObserver<T>,
) => TObserver<T>

Applies a callback function to the values emitted by an observer.

Type declaration

Other

debounce: (delay?: number) => TObserver<Data>

Creates a debounced observer with an optional delay.

Type declaration

    • (delay?: number): TObserver<Data>
    • Parameters

      • Optionaldelay: number

        The delay in milliseconds before emitting the data.

      Returns TObserver<Data>

      • The debounced observer.
delay: (delay?: number) => TObserver<Data>

Creates a delayed observer with an optional delay.

Type declaration

    • (delay?: number): TObserver<Data>
    • Parameters

      • Optionaldelay: number

        The delay in milliseconds before emitting the data.

      Returns TObserver<Data>

      • The delayed observer.
filter: (callbackfn: (value: Data) => boolean) => TObserver<Data>

Applies a filtering function to the observer and returns a new observer with filtered values.

Type declaration

    • (callbackfn: (value: Data) => boolean): TObserver<Data>
    • Parameters

      • callbackfn: (value: Data) => boolean

        A function that tests each value in the observer. Should return true or false.

      Returns TObserver<Data>

      • A new observer with filtered values.
flatMap: <T = any>(callbackfn: (value: Data) => T[]) => TObserver<T>

Applies a transformation function to each value emitted by the observer and flattens the result into a single observer.

Type declaration

    • <T = any>(callbackfn: (value: Data) => T[]): TObserver<T>
    • Type Parameters

      • T = any

        The type of values emitted by the observer.

      Parameters

      • callbackfn: (value: Data) => T[]

        The transformation function to apply to each value emitted by the observer.

      Returns TObserver<T>

      • The observer that emits the flattened values.
map: <T = any>(callbackfn: (value: Data) => T) => TObserver<T>

Maps the values of the observer using the given callback function.

Type declaration

    • <T = any>(callbackfn: (value: Data) => T): TObserver<T>
    • Type Parameters

      • T = any

        The type of the mapped values.

      Parameters

      • callbackfn: (value: Data) => T

        A function that maps each value of the observer.

      Returns TObserver<T>

      • An observer with the mapped values.
mapAsync: <T = any>(
    callbackfn: (value: Data) => Promise<T>,
    fallbackfn?: (e: Error) => void,
) => TObserver<T>

Asynchronously maps the emitted values of the observer using the provided callback function.

Type declaration

    • <T = any>(
          callbackfn: (value: Data) => Promise<T>,
          fallbackfn?: (e: Error) => void,
      ): TObserver<T>
    • Type Parameters

      • T = any

        The type of the mapped values.

      Parameters

      • callbackfn: (value: Data) => Promise<T>

        The callback function that maps the emitted values of the observer.

      • Optionalfallbackfn: (e: Error) => void

        The optional fallback function that handles errors during mapping.

      Returns TObserver<T>

      • Returns a new observer that emits the mapped values.
merge: <T = any>(observer: TObserver<T>) => TObserver<Data | T>

Merges the provided observer with the current observer instance. Returns a new observer that emits values from both observers.

Type declaration

  • Calls the next method to emit the specified data using the SUBJECT_EVENT event.

    Parameters

    • data: Data

      The data to be emitted.

    Returns Promise<void>

    • Resolves when the emission is complete.
once: (callback: Function) => () => void

Executes the provided callback function only once. The callback function will be invoked when the specified event occurs for the first time.

Type declaration

    • (callback: Function): () => void
    • Parameters

      • callback: Function

        The function to be executed only once.

      Returns () => void

      • A function that removes the registered event listener.
reduce: <T = any>(
    callbackfn: (acm: T, cur: Data) => T,
    begin: T,
) => TObserver<T>

Applies a reducer function to each value emitted by the observer and returns a single accumulated value.

Type declaration

    • <T = any>(callbackfn: (acm: T, cur: Data) => T, begin: T): TObserver<T>
    • Type Parameters

      • T = any

        The type of the accumulated value and emitted values

      Parameters

      • callbackfn: (acm: T, cur: Data) => T

        A function that accepts the accumulated value and the current emitted value, and returns the new accumulated value

      • begin: T

        The initial value for the accumulator

      Returns TObserver<T>

      • An observer that emits the accumulated value when the original observer completes
repeat: (interval?: number) => TObserver<Data>

Creates an observer that repeats emitting values at a specified interval.

Type declaration

    • (interval?: number): TObserver<Data>
    • Parameters

      • Optionalinterval: number

        The time interval at which to repeat emitting values.

      Returns TObserver<Data>

      • The created observer.
split: () => Observer<
    readonly (
        Data extends readonly InnerArr[]
            ? InnerArr extends readonly InnerArr[]
                ? InnerArr extends readonly InnerArr[]
                    ? InnerArr extends readonly InnerArr[]
                        ? InnerArr extends readonly InnerArr[]
                            ? InnerArr extends readonly InnerArr[]
                                ? InnerArr extends readonly (...)[]
                                    ? (...) extends (...) ? (...) : (...)
                                    : InnerArr
                                : InnerArr
                            : InnerArr
                        : InnerArr
                    : InnerArr
                : InnerArr
            : Data
    )[],
>

Splits the observed data into batches of arrays.

Type declaration

    • (): Observer<
          readonly (
              Data extends readonly InnerArr[]
                  ? InnerArr extends readonly InnerArr[]
                      ? InnerArr extends readonly InnerArr[]
                          ? InnerArr extends readonly InnerArr[]
                              ? InnerArr extends readonly InnerArr[]
                                  ? InnerArr extends readonly InnerArr[]
                                      ? InnerArr extends readonly (...)[]
                                          ? (...) extends (...) ? (...) : (...)
                                          : InnerArr
                                      : InnerArr
                                  : InnerArr
                              : InnerArr
                          : InnerArr
                      : InnerArr
                  : Data
          )[],
      >
    • Returns Observer<
          readonly (
              Data extends readonly InnerArr[]
                  ? InnerArr extends readonly InnerArr[]
                      ? InnerArr extends readonly InnerArr[]
                          ? InnerArr extends readonly InnerArr[]
                              ? InnerArr extends readonly InnerArr[]
                                  ? InnerArr extends readonly InnerArr[]
                                      ? InnerArr extends readonly (...)[]
                                          ? (...) extends (...) ? (...) : (...)
                                          : InnerArr
                                      : InnerArr
                                  : InnerArr
                              : InnerArr
                          : InnerArr
                      : InnerArr
                  : Data
          )[],
      >

      • The observer that emits batches of arrays.
subscribe: (callback: Function) => () => void

Subscribes to an event.

Type declaration

    • (callback: Function): () => void
    • Parameters

      • callback: Function

        The callback function to be invoked when the event is triggered.

      Returns () => void

      • A function to unsubscribe from the event.
tap: (callbackfn: (value: Data) => void) => TObserver<Data>

The tap function allows you to perform side effects without modifying the observed data.

toIteratorContext: () => {
    done(): void;
    iterate(): AsyncGenerator<Data, void, unknown>;
}

Converts the current object to an iterator context.

Type declaration

    • (): { done(): void; iterate(): AsyncGenerator<Data, void, unknown> }
    • Returns { done(): void; iterate(): AsyncGenerator<Data, void, unknown> }

      The iterator context representing the current object.

toPromise: () => Promise<Data>

Converts an observer-based asynchronous operation into a promise-based asynchronous operation.

Type declaration

    • (): Promise<Data>
    • Returns Promise<Data>

      A promise representing the completion or failure of the asynchronous operation.

toPromise

unsubscribeAll: () => void

Unsubscribes all event listeners.

Type declaration

    • (): void
    • Returns void

      • No return value.

unsubscribeAll