CERNY.event.Observable
This script provides a function
Observable
to make an object call observers when events occur.
Observable
should be called on the prototype of a constructor, but it can also be called on individual objects. The first option is preferable, because it is faster and only attaches the methods to the prototype and not to every single instance.
Observable attaches the methods
addObserver
,
removeObserver
,
removeObservers
and
notify
to the object.
On the first call to
addObserver
the object receives a property
_observableObservers
.
Uses
Functions
Observable
Makes an object observable.
addObserver
Add an observer (a function) to to be called when event occurs.
notify
Notify all observers of event.
removeObserver
Remove an observer.
removeObservers
Remove observers. If an event is passed, only observers of that event will be removed. Otherwise all observers will be removed.

