Class ObserverEmitter<TEvent>Abstract Internal

An emitter implementation consisting of a set of observers.

Type Parameters

  • TEvent

Hierarchy (view full)

Constructors

Properties

observers: Set<Observer<TEvent>> = ...

Accessors

  • get observed(): boolean
  • Returns boolean

    True if this emitter has any observers, false otherwise.

Methods

  • Called after all observers have been detached.

    Returns void

  • Emit an event to observers.

    Parameters

    • event: TEvent

      The event to emit.

    Returns void

  • Filter events emitted by this emitter.

    Parameters

    • f: ((event) => boolean)

      The predicate to apply to each event.

        • (event): boolean
        • Parameters

          Returns boolean

    Returns Emitter<TEvent>

    An emitter than only emits events emitted by this emitter for which f returns true.

  • Creates an emitter that counts events emitted by this emitter.

    Returns Emitter<number>

    An emitter that emits the index, starting at zero, of every event emitted by this emitter.

  • Apply a function to all events and their index (starting at zero) emitted by this emitter.

    Type Parameters

    • TOut

    Parameters

    • f: ((event, index) => TOut)

    Returns Emitter<TOut>

    An emitter that applies the function f to all events emitted by this emitter.

  • Called before the first observer is attached.

    Returns void

  • Apply a function to all events emitted by this emitter.

    Type Parameters

    • TOut

    Parameters

    • f: ((event) => TOut)

      The function to apply to events.

    Returns Emitter<TOut>

    An emitter that applies the function f to all events emitted by this emitter.

  • Create a promise that resolves the next time an event is emitted by this emitter.

    Returns Promise<TEvent>

    A promise that resolves to the next event emitted by this emitter.

  • Attach an observer.

    Parameters

    Returns (() => void)

    A function that can be called to detach the observer. Alternatively unobserve can be called.

      • (): void
      • Returns void

  • Create an emitter from another observable (cell or emitter). The resulting emitter emits an even whenever the input observable emits an event.

    Type Parameters

    • TEvent

    Parameters

    Returns Emitter<TEvent>

    An emitter that emits the same events as observable.