Callback's can use the this object in order to act normally without reinvoking themselves.
Value onGet(String propertyName, Value value, hadAlready)
Returns the value at a specific index
Value onSet(String propertyName, Value oldValue, Value value, hadAlready)
Returns the value to save at a specific index
Array onForeach()
Returns an array containing all the index keys for this object
Boolean onQuery(String propertyName, Value value, hadAlready)
Returns whether the object has a specific index
Boolean onDelete(String propertyName, Value value, hadAlready)
Returns whether the object was successful in deleting a specific index
##example
####Code
//print out any property gets that use the . operatorvar debug = Watchable( function(propertyName,value,hadAlready){ //check the type of the object contained by value //undefined if no value, or number if using []'s with a number if(typeof value === "string") { sys.puts(propertyName); } return value; } function(propertyName,oldValue,value,hadAlready) { return value; })debug.hellodebug[" world!"]
####Output
hello world!
##uses
Debugging - Show what is being accessed / set
False natives - refuse to allow properties to be set / got beyond a specified few
Dynamic programming - Fib[3] could compute Fib[1] and Fib[2]
Index based getters / setters - Fib[0] cannot have a getter set normally because it is a number not string based index (all non-number non-undefined values become string based).