-
-
Save danwrong/874891 to your computer and use it in GitHub Desktop.
This file contains 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
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