Skip to content

Instantly share code, notes, and snippets.

@danwrong
Created March 17, 2011 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danwrong/874891 to your computer and use it in GitHub Desktop.
Save danwrong/874891 to your computer and use it in GitHub Desktop.
function Sequence(deps) {
this.deps = deps;
}
Sequence.prototype = new Dependency;
Sequence.prototype.start = function() {
var me = this, nextDep = 0, allResults = [];
(function next() {
var dep = me.deps[nextDep++];
if (dep) {
dep.then(function(results) {
if (dep.results.length > 0) {
allResults.concat(rep.results);
}
next();
});
} else {
me.complete(allResults);
}
}());
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment