Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.Zee = window.Zee || {};
- (function() {
- Zee.CallbackChain = function() {
- return new callbackChain();
- };
- // private object
- var callbackChain = function() {
- var me = this;
- me.queue = [];
- me.current = 0;
- me.add = function(fn) {
- me.queue.push(fn);
- return me;
- };
- me.run = function(next) {
- if((next = me.queue[me.current++])) {
- next(me.run);
- }
- return me;
- };
- };
- })();
Add Comment
Please, Sign In to add comment