Skip to main content

Observable <T>

Simple Observable implementation

Index

Constructors

constructor

  • Type parameters

    • T

      is the typescript Type that defines the data being observed

    Returns Observable<T>

Properties

publicobservers

observers: Observer<T>[] = []

publicsubscriptions

subscriptions: (val: T) => any[] = []

Methods

clear

  • clear(): void
  • Removes all observers and callbacks


    Returns void

notifyAll

  • notifyAll(message: T): void
  • Broadcasts a message to all observers and callbacks


    Parameters

    • message: T

    Returns void

register

  • Register an observer to listen to this observable


    Parameters

    Returns void

subscribe

  • subscribe(func: (val: T) => any): void
  • Register a callback to listen to this observable


    Parameters

    • func: (val: T) => any

      Returns void

    unregister

    • Remove an observer from the observable


      Parameters

      Returns void

    unsubscribe

    • unsubscribe(func: (val: T) => any): void
    • Remove a callback that is listening to this observable


      Parameters

      • func: (val: T) => any

        Returns void