Guest User

Untitled

a guest
Jun 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. window.Zee = window.Zee || {};
  2.  
  3. (function() {
  4. Zee.CallbackChain = function() {
  5. return new callbackChain();
  6. };
  7.  
  8. // private object
  9. var callbackChain = function() {
  10. var me = this;
  11. me.queue = [];
  12. me.current = 0;
  13. me.add = function(fn) {
  14. me.queue.push(fn);
  15. return me;
  16. };
  17. me.run = function(next) {
  18. if((next = me.queue[me.current++])) {
  19. next(me.run);
  20. }
  21. return me;
  22. };
  23. };
  24. })();
Add Comment
Please, Sign In to add comment