Skip to content

Instantly share code, notes, and snippets.

@zhang6464
Created October 11, 2014 10:59
Show Gist options
  • Save zhang6464/acd62238ad99822a18af to your computer and use it in GitHub Desktop.
Save zhang6464/acd62238ad99822a18af to your computer and use it in GitHub Desktop.
javascript queueable event handler.
var handler = new Handler();
function Handler(){
var queues = [];
this.addQueue = function( method ){
queues.push(method);
}
this.removeQueue = function( method ){
queues.splice(queues.indexOf(method)-1, 1);
}
this.exports = function(){
for( var i = 0;i < queues.length; i++ ){
queues[i]();
}
}
}
window.onload = handler.exports;
handler.addQueue( function(){
console.log(1);
});
//handler.removeQueue( function(){
// console.log(1);
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment