mirror of
https://github.com/vale981/event-pubsub
synced 2025-03-05 09:31:42 -05:00
added ability to remove all events
This commit is contained in:
parent
425ccc5afd
commit
851d0219dc
3 changed files with 49 additions and 5 deletions
|
@ -10,6 +10,19 @@ function sub(type,handler){
|
||||||
function unsub(type,handler){
|
function unsub(type,handler){
|
||||||
checkScope.apply(this);
|
checkScope.apply(this);
|
||||||
|
|
||||||
|
if(type=='*'){
|
||||||
|
delete this._events_['*'];
|
||||||
|
for(
|
||||||
|
var keys = Object.keys(this._events_),
|
||||||
|
count = keys.length,
|
||||||
|
i=0;
|
||||||
|
i<count;
|
||||||
|
i++
|
||||||
|
){
|
||||||
|
this.off(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!this._events_[type])
|
if(!this._events_[type])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -21,8 +34,8 @@ function unsub(type,handler){
|
||||||
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)
|
||||||
delete this._events_[type][i];
|
delete this._events_[type][i];
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,6 +34,8 @@ events.on(
|
||||||
'world',
|
'world',
|
||||||
function(data){
|
function(data){
|
||||||
console.log('World event got',data);
|
console.log('World event got',data);
|
||||||
|
events.off('*');
|
||||||
|
console.log('Removed all events');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
29
package.json
Normal file
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "event-pubsub",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"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": {
|
||||||
|
"example": "examples"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/RIAEvangelist/event-pubsub.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"event",
|
||||||
|
"events",
|
||||||
|
"pubsub",
|
||||||
|
"node",
|
||||||
|
"browser"
|
||||||
|
],
|
||||||
|
"author": "Brandon Nozaki Miller",
|
||||||
|
"license": "Unlicense",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/RIAEvangelist/event-pubsub/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/RIAEvangelist/event-pubsub"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue