cleanup es6 fixes to es5

This commit is contained in:
Brandon Miller 2017-08-23 03:18:05 -07:00
parent eb51b6e17b
commit 73d5ab559f
3 changed files with 16 additions and 3 deletions

10
es5.js
View file

@ -66,15 +66,23 @@ function EventPubSub() {
arguments.splice(0,1);
var handlers=this._events_[type];
var onceHandled=[];
for(var i in handlers){
var handler=handlers[i];
handler.apply(this, arguments);
if(handler._once_){
this.off(type,handler);
onceHandled.push(handler);
}
}
for(var i in onceHandled){
this.off(
type,
onceHandled[i]
);
}
return this;
}

1
es6.js
View file

@ -68,7 +68,6 @@ class EventPubSub {
const onceHandled=[];
for ( let handler of handlers ) {
console.log(handler)
handler.apply( this, args );
if(handler._once_){
onceHandled.push(handler);

View file

@ -18,7 +18,8 @@ const events=new Events;
'test.once',
(data)=>{
console.log(`got data ${data} from .on with true`)
}
},
true
);
/************************************\
@ -28,3 +29,8 @@ events.emit(
'test.once',
'-TESTING-'
);
events.emit(
'test.once',
'-NEVER SEE THIS-'
);