Let's suppose I want to create a javascript class/object/function which have a method that can accept a callback object like this:
callbacks = {
onSuccess : // method to be executed in case of success
onComplete : // method to be executed in case of complete
onFailure : // method to be executed in case of failure
onError : // method to be executed in case of an error
}
So let's suppose the classes name definition are the following:
var Obj = function () {};
Obj.prototype.exec = function (callbacks, event, caller, argument) {
}
And I want to use the object in this way:
var mytest = new Test();
var myObj = new Obj();
Obj.exec(callbacks,["onSuccess", "onComplete"], mytest, arguments);
How should Obj.prototype.exec be implemented?
onSuccesssupposed to be one of those callbacks?