You can call your methods with call
or apply
to force a particular this
value:
Reactor.prototype.dispatchEvent = function(eventName, eventArgs){
for(var i in this.events[eventName].callbacks) {
this.events[eventName].callbacks[i].apply(this, eventArgs);
}
};
(assuming eventArgs
is an array, the callback will be called with each element from the array passed as a separate argument)