backwards compatibility broken for removing all handlers

This commit is contained in:
Brandon Nozaki Miller 2016-07-11 08:38:08 -07:00
parent 772ad646c9
commit 3084bed2a7
5 changed files with 26 additions and 18 deletions

2
.tags
View file

@ -44,4 +44,4 @@ type package.json /^ "type": "git",$/;" f
unsub event-pubsub.js /^function unsub(type,handler){$/;" f
url package.json /^ "url": "https:\/\/github.com\/RIAEvangelist\/event-pubsub.git"$/;" f
url package.json /^ "url": "https:\/\/github.com\/RIAEvangelist\/event-pubsub\/issues"$/;" f
version package.json /^ "version": "1.0.6",$/;" f
version package.json /^ "version": "2.0.0",$/;" f

View file

@ -52,7 +52,7 @@ Easy for any developer level. No frills, just high speed pubsub events!
events.on(
'removeEvents',
function(){
events.off('*');
events.off('*','*');
console.log('Removed all events');
}
);
@ -106,7 +106,7 @@ Easy for any developer level. No frills, just high speed pubsub events!
events.on(
'removeEvents',
function(){
events.off('*');
events.off('*','*');
console.log('Removed all events');
}
);

View file

@ -16,6 +16,10 @@ window.pubsub=(
}
function unsub(type,handler){
if(!handler){
var err=new ReferenceError('handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler');
throw err;
}
checkScope.apply(this);
if(type=='*'){
@ -35,7 +39,7 @@ window.pubsub=(
if(!this._events_[type])
return;
if(!handler){
if(handler=='*'){
delete this._events_[type];
return;
}

View file

@ -13,6 +13,10 @@ function sub(type,handler){
}
function unsub(type,handler){
if(!handler){
var err=new ReferenceError('handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler');
throw err;
}
checkScope.apply(this);
if(type=='*'){
@ -32,7 +36,7 @@ function unsub(type,handler){
if(!this._events_[type])
return;
if(!handler){
if(handler=='*'){
delete this._events_[type];
return;
}

View file

@ -1,6 +1,6 @@
{
"name": "event-pubsub",
"version": "1.0.6",
"version": "2.0.0",
"description": "Pubsub events for Node and the browser allowing event scoping and multiple scopes. Easy for any developer level. No frills, just high speed pubsub events!",
"main": "event-pubsub.js",
"directories": {