Open wirthmi opened 10 years ago
The whole documentation needs an update...
trigger: function(event) {
// First make sure there are any listeners, then check for any listeners
// on this specific event, if not, early out.
if(this.listeners && this.listeners[event]) {
var args = [].slice.call(arguments, 1);
// Call each listener in the context of either the target passed into
// `on` or the object itself.
for(var i=0,len = this.listeners[event].length;i<len;i++) {
var listener = this.listeners[event][i];
listener[1].apply(listener[0], args);
}
}
},
I think if the trigger method is changed to above code than any number of arguments can be passed.
In this implementation the strain on the GC is too much - trigger is called a lot (thousands of times a second in many games), so calling slice (which creates a new array with the result each time) will result in lots and lots of objects being created (even if [].slice was rewritten as Array.prototype.slice)
you are right :) thanks for the info.
Hello,
I've noticed that in Core Quintus Basics chapter of Guide accessible on Quintus website is written that up to 3 arguments can be passed to event handlers when triggering some event. It doesn't work. According to implementation of trigger() method in Evented class only one argument can be passed to handlers. IMHO possibility to pass up to 3 arguments would be nice and handy.