This script provides a function
to make an object call observers when events occur.
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
to the object.
On the first call to
the object receives a property
Makes an object observable.
Add an observer (a function) to to be called when event occurs.
Notify all observers of event.
Remove an observer.
Remove observers. If an event is passed, only observers of that event will be removed. Otherwise all observers will be removed.