Title / Description
Code function QueueObject(model, fn, args, type) { var queue = []; var model = model; var fn = fn; var args = args; this.push = function (queueObject) { queue.push(queueObject); } this.run = function() { var action = function() { var modelOrPromise = fn.call(model, args); if (modelOrPromise.then) { modelOrPromise.then(function() { if (model.get('actionQueue')) {model.get('actionQueue').next()} }) } else { if (model.get('actionQueue')) {model.get('actionQueue').next()} } } if (model.get('isDeleted')) { model.set('actionQueue', null); } else if (model.get('isSaving')) { model.one('didSave', action); } else { action.call(); } } this.next = function () { var next = queue.shift(); if (next) { next.run(); } else { model.set('actionQueue', null); } } }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code