CERNY.event.Revertable
This script provides a function
Revertable
to make an object revertable. Given a list of properties and their types (optional), it creates getters and setters for these properties. These setters will notify observers, whether the instance has been changed or reverted. Thus a Revertable is always an Observable.
Revertable should be called on the prototype of a constructor, see
Observable
for more information.
The object receives the methods
set
,
get
,
commit
,
revert
and
hasChanged
.
set
and
get
are called by the setters respectively getters, but can also be called directly.
The object will receive the property
_revertableProperties
on calling Revertable. On the first setter call, it will additionally receive the properties
_revertableChangeCount
and
_revertableOriginal
.
Provided type information, the setters and getters will receive a signature.
Used by
Functions
Revertable
Makes an object revertable.
The object will be able to keep track of its changed status, given that properties are set with the provided set method.
The properties which are of interest and contribute to the identity of the object must be passed to this function.
On setting values by the means of set the object will announce the events Revertable.EVT_CHANGE and Revertable.EVT_REVERT.
If type is ommited for a property by passing just the name of the property in the properties array, no signature will be defined on the getter and setter
commit
Commit the object. The current state becomes the original state.
hasChanged
Determine, if this object has changed.
revert
Revert the object to its orignial state.

