MCPcopy Create free account
hub / github.com/apache/cloudstack / all

Function all

tools/ngui/static/js/lib/angular.js:7013–7034  ·  view source on GitHub ↗

* @ngdoc * @name ng.$q#all * @methodOf ng.$q * @description * Combines multiple promises into a single promise that is resolved when all of the input * promises are resolved. * * @param {Array. } promises An array of promises. * @returns {Promise} Returns a single pro

(promises)

Source from the content-addressed store, hash-verified

7011 * same rejection.
7012 */
7013 function all(promises) {
7014 var deferred = defer(),
7015 counter = promises.length,
7016 results = [];
7017
7018 if (counter) {
7019 forEach(promises, function(promise, index) {
7020 ref(promise).then(function(value) {
7021 if (index in results) return;
7022 results[index] = value;
7023 if (!(--counter)) deferred.resolve(results);
7024 }, function(reason) {
7025 if (index in results) return;
7026 deferred.reject(reason);
7027 });
7028 });
7029 } else {
7030 deferred.resolve(results);
7031 }
7032
7033 return deferred.promise;
7034 }
7035
7036 return {
7037 defer: defer,

Callers 5

parse_input_runtcsMethod · 0.50
moveMethod · 0.50
elements_equalMethod · 0.50
test_01_sys_vm_startMethod · 0.50

Calls 3

deferFunction · 0.85
forEachFunction · 0.85
refFunction · 0.85

Tested by 3

elements_equalMethod · 0.40
test_01_sys_vm_startMethod · 0.40