An Observer is notified whenever something changes in a Subject it is observing. The change can be in the value of a Subject's Parameter, or the occurrence of an event such as a GenericEvent. When a change occurs in the Subject, the Subject.broadcast method calls the Observer's observe method.

The Observer is connected to the Subject via the Subject.addObserver method. This is typically done in the Observer's constructor or by the entity that creates the Observer.

Implements the Observer design pattern. See Subject for more extensive documentation.

interface Observer {
    observe(event): void;
    toStringShort(): string;
}

Hierarchy (view full)

Implemented by

Methods

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc