Docs (4.0.0)
Event handling

class Observer

The base class for an observer that watches a particular ManagedObject.

class Observer<T extends ManagedObject = ManagedObject>

Description

Observers can be used to watch particular objects (instances of ManagedObject or any subclass, including ManagedList, ManagedRecord, etc.), specifically to:

Before any property can be observed, the observeProperty*() method must be called. This should be done within the observe() method, which must be overridden. Refer to the examples below.

Observers can be created manually (using new, and the observe() method), but they can also be passed to ManagedObject.attach() and ManagedObject.autoAttach() to observe attached objects. Refer to the examples below.

The observer is automatically stopped when the target is unlinked, but it can also be stopped manually (see stop()). This may be necessary to avoid memory leaks, since observers are linked to the observed object while they’re active — keeping them (and any referenced objects) from being freed up by the JavaScript garbage collector as long as the observed object is referenced itself.

Constructor

  • constructor()Creates a new observer, without observing any object yet.

Instance Members