Created
April 19, 2016 17:37
-
-
Save ry8806/a221ade48dd88cdaf8a92ca26612b112 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
var promise1 = getFirstValue().then(function (value) { | |
return value; | |
}); | |
// DON'T DO THIS | |
var p2 = $q.defer(); | |
p2.resolve("A value that is instant but we're faffing around with it"); | |
var promise2 = p2.deferred; | |
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