API

Interface IReadonlyObservable<T>

An interface that defines the reader side of an Observable (receive notifications).

interface IReadonlyObservable<T = unknown> {
    add(
        callback: (eventData: T, eventState: EventState) => void,
        mask?: number,
        insertFirst?: boolean,
        scope?: unknown,
        unregisterOnFirstCall?: boolean,
    ): IObserver;
    addOnce(
        callback: (eventData: T, eventState: EventState) => void,
    ): IObserver;
}

Type Parameters

  • T = unknown

Implemented by

Index
  • Create a new Observer with the specified callback

    Parameters

    • callback: (eventData: T, eventState: EventState) => void

      the callback that will be executed for that Observer

    • Optionalmask: number

      the mask used to filter observers

    • OptionalinsertFirst: boolean

      if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.

    • Optionalscope: unknown

      optional scope for the callback to be called from

    • OptionalunregisterOnFirstCall: boolean

      defines if the observer as to be unregistered after the next notification

    Returns IObserver

    the new observer created for the callback