Skip to content

Instantly share code, notes, and snippets.

@mosfet1kg
Created July 31, 2015 06:43
Show Gist options
  • Save mosfet1kg/e5a5a685e19085f3a093 to your computer and use it in GitHub Desktop.
Save mosfet1kg/e5a5a685e19085f3a093 to your computer and use it in GitHub Desktop.
Q sequence
var result = Q();
func.push(function(){
var d = Q.defer();
d.resolve('a');
return d.promise;
});
func.push(function(){
console.log(arguments);
var d = Q.defer();
d.resolve('b');
return d.promise;
});
func.push(function(){
console.log(arguments);
var d = Q.defer();
d.resolve('c');
return d.promise;
});
func.forEach(function(f){
result = result.then(f);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment