Fix for *,* or someEvent,* thanks to @hxsf and @conordickinson

This commit is contained in:
SSMP 2016-08-26 18:13:30 -07:00
parent af149485e2
commit aa34d14485
2 changed files with 9 additions and 24 deletions

View file

@ -19,28 +19,13 @@ function unsub(type,handler){
}
checkScope.apply(this);
if(type=='*'){
var params=Array.prototype.slice.call(arguments,1);
for(
var keys = Object.keys(this._events_),
count = keys.length,
i=0;
i<count;
i++
){
params.unshift(keys[i]);
this.off.apply(this,params);
}
if(handler=='*'){
delete this._events_[type];
}
if(!this._events_[type])
return;
if(handler=='*'){
delete this._events_[type];
return;
}
for(var i=0,
count=this._events_[type].length;
i<count;

View file

@ -34,7 +34,7 @@ events.on(
'world',
function(data){
console.log('World event got',data);
events.off('*');
events.off('*','*');
console.log('Removed all events');
}
);