View Full Version : Ext.util.Event.fire()

9 Mar 2007, 10:32 AM
fire : function(){
var ls = this.listeners, scope, len = ls.length;
if(len > 0){
this.firing = true;
var args = Array.prototype.slice.call(arguments, 0);
for(var i = 0; i < len; i++){
var l = ls[i];
if(l.fireFn.apply(l.scope, arguments) === false){
return false;
this.firing = false;
return true;

If one of the listerners return false, this.firing = true is not reset to false, is this ok?


9 Mar 2007, 10:36 AM
It's just a minor detail. I see that this.firing is a flag for add/remove listerner method to tell if it can just slice the listerner array or make a copy first.

One question though, since javascript is single threaded, why is this necessary?


9 Mar 2007, 11:57 PM
That is indeed an oversight. Thanks for pointing it out.

The reason for the flag is because a listener can remove itself in the handler call (e.g. a 1 time listener) and break the loop.