Created
October 11, 2014 10:59
-
-
Save zhang6464/acd62238ad99822a18af to your computer and use it in GitHub Desktop.
javascript queueable event handler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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