Skip to content

Instantly share code, notes, and snippets.

@ry8806
Last active April 19, 2016 17:29
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 ry8806/0cf5b41adfa8a87f83af1bc5a08e49eb to your computer and use it in GitHub Desktop.
Save ry8806/0cf5b41adfa8a87f83af1bc5a08e49eb to your computer and use it in GitHub Desktop.
var promise1 = getFirstValue().then(function (value) {
return value;
});
// We can just return a value without creating a promise if we don't need.
var promise2 = "A value that is instant";
var promise3 = getThirdValue().then(function (value) {
return value;
});
var promise4 = getFourthValue().then(function (value) {
return value;
});
var theResults = [];
$q.all([promise1, promise2, promise3, promise4]).then(function(result){
for (var i = 0; i < result.length; i++){
theResults.push(result[i]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment