fixed bug elrroniously removing last event even if not a match

This commit is contained in:
Brandon Nozaki Miller 2016-07-11 03:17:17 -07:00
parent 71e526d724
commit 65bd9b289b
4 changed files with 137 additions and 64 deletions

47
.tags Normal file
View file

@ -0,0 +1,47 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
_log_ examples/browser/basic.js /^function _log_ (){$/;" c
_log_ examples/browser/multipleScopes.js /^function _log_ (){$/;" c
_log_ examples/browser/objectScope.js /^function _log_ (){$/;" c
author package.json /^ "author": "Brandon Nozaki Miller",$/;" f
authors bower.json /^ "authors": [$/;" f
bugs package.json /^ "bugs": {$/;" f
checkScope event-pubsub.js /^function checkScope(){$/;" f
description bower.json /^ "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!",$/;" f
description package.json /^ "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!",$/;" f
directories package.json /^ "directories": {$/;" f
eventLog examples/browser/basic.js /^var eventLog=document.getElementById('events');$/;" v
eventLog examples/browser/multipleScopes.js /^var eventLog=document.getElementById('events');$/;" v
eventLog examples/browser/objectScope.js /^var eventLog=document.getElementById('events');$/;" v
example package.json /^ "example": "examples"$/;" f
homepage bower.json /^ "homepage": "https:\/\/github.com\/RIAEvangelist\/event-pubsub",$/;" f
homepage package.json /^ "homepage": "https:\/\/github.com\/RIAEvangelist\/event-pubsub"$/;" f
ignore bower.json /^ "ignore": [$/;" f
init event-pubsub.js /^function init(scope){$/;" f
keywords bower.json /^ "keywords": [$/;" f
keywords package.json /^ "keywords": [$/;" f
license bower.json /^ "license": "DBAD",$/;" f
license package.json /^ "license": "Unlicense",$/;" f
main bower.json /^ "main": "event-pubsub.js",$/;" f
main package.json /^ "main": "event-pubsub.js",$/;" f
moduleType bower.json /^ "moduleType": [$/;" f
name bower.json /^ "name": "event-pubsub",$/;" f
name package.json /^ "name": "event-pubsub",$/;" f
pub event-pubsub.js /^function pub(type){$/;" f
pubsub examples/node/multipleScopes.js /^var pubsub = require('..\/..\/event-pubsub.js');$/;" v
pubsub examples/node/objectScope.js /^var pubsub = require('..\/..\/event-pubsub.js');$/;" v
repository package.json /^ "repository": {$/;" f
scripts package.json /^ "scripts": {$/;" f
sub event-pubsub.js /^function sub(type,handler){$/;" f
test package.json /^ "test": "echo \\"Error: no test specified\\" && exit 1"$/;" f
thing.id examples/browser/objectScope.js /^var thing={$/;" p
thing.id examples/node/objectScope.js /^var thing={$/;" p
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.3",$/;" f

28
bower.json Normal file
View file

@ -0,0 +1,28 @@
{
"name": "event-pubsub",
"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",
"authors": [
"Brandon Nozaki Miller"
],
"license": "DBAD",
"keywords": [
"event",
"events",
"pubsub",
"node",
"browser"
],
"homepage": "https://github.com/RIAEvangelist/event-pubsub",
"moduleType": [
"globals",
"node"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

View file

@ -35,19 +35,18 @@ window.pubsub=(
return; return;
} }
if(this._events_[type].length<2){
delete this._events_[type];
return;
}
for(var i=0, for(var i=0,
count=this._events_[type].length; count=this._events_[type].length;
i<count; i<count;
i++ i++
){ ){
if(this._events_[type][i]==handler) if(this._events_[type][i]==handler){
this._events_[type].splice(i,1); this._events_[type].splice(i,1);
return; }
}
if(this._events_[type].length<1){
delete this._events_[type];
} }
} }

View file

@ -32,19 +32,18 @@ function unsub(type,handler){
return; return;
} }
if(this._events_[type].length<2){
delete this._events_[type];
return;
}
for(var i=0, for(var i=0,
count=this._events_[type].length; count=this._events_[type].length;
i<count; i<count;
i++ i++
){ ){
if(this._events_[type][i]==handler) if(this._events_[type][i]==handler){
this._events_[type].splice(i,1); this._events_[type].splice(i,1);
return; }
}
if(this._events_[type].length<1){
delete this._events_[type];
} }
} }