|
|
jsobjex
jsobjex module
jsobjex module
home > JSLibs > jsobjex -![]()
Description
jsobjex is a module that contains only ObjEx class.
Exemples
code snippet
jsobjex::ObjEx class
home > JSLibs > jsobjex > ObjEx -![]()
Description
This class give the ability to spy properties changes. One can listen for add, del, set and set events on the object.It is possible to store an hidden auxiliary object that can be access using ObjEx.Aux( ObjEx object ) static function.
Functions
- constructor ObjEx( addCallback, delCallback, getCallback, setCallback, auxObject )
note:
addCallback, delCallback, getCallback, setCallback can be undefined.
Static Functions
- value Aux( ObjEx object )
Returns the auxObject stored in the ObjEx object.
Events / Callbacks
function addCallback, delCallback, getCallback, setCallback are called according to the operation done on the object.arguments are: ( propertyName, propertyValue, auxObject, callbackIndex )
- propertyName : the name of the property being handled
- propertyValue : the value of the property being handled
- auxObject : the auxObject provided to the constructor
- callbackIndex : an integer that has the folowing value: 0 for addCallback, 1 for delCallback, 2 for getCallback, 3 for setCallback.
Example
function addCallback( name, value ) {
Print('adding ' + name + ' = ' + value);
}
var obj = new ObjEx( addCallback, undefined, undefined, undefined, null );
obj.foo = 123;
obj.foo = 456;prints:
adding foo = 123
Note that addCallback is called only when the property is being added, in opposition to setCallback that is called each time the value is changed.
Example
http://jsircbot.googlecode.com/svn/trunk/dataObject.js
Sign in to add a comment

