A simple implementation of the observable pattern.

Hierarchy-Diagram

UML class diagram of Observable
Legend
icon for a class in the UML class diagram class
icon for a public property in the UML class diagram public property
icon for a public method in the UML class diagram public method

Hierarchy (view full)

Constructors

Properties

observers: any = null

Methods

  • Notifies the Observers about an event of the Observable.

    The sent data is part of the contract between the Observable and its Observers

    Parameters

    • Rest...args: any

    Returns void

  • Notifies the Observers about an event of the Observable.

    This is the asynchronous variant of notify as asynchronous observers can be called The sent data is part of the contract between the Observable and its Observers

    Parameters

    • Rest...args: any

    Returns Promise<void>

  • Subscribes a function as an Observer.

    Supports also first time notification by providing additional arguments. This must be done by overriding this function in the Observable and providing the relevant argument(s).

    Parameters

    • func: any
    • Rest...args: any

    Returns void