MCPcopy Create free account
hub / github.com/angular-ui/ui-router / all

Function all

test/angular/1.5/angular.js:16909–16929  ·  view source on GitHub ↗

* @ngdoc method * @name $q#all * @kind function * * @description * Combines multiple promises into a single promise that is resolved when all of the input * promises are resolved. * * @param {Array. |Object. } promises An array or hash of promises. * @retur

(promises)

Source from the content-addressed store, hash-verified

16907 */
16908
16909 function all(promises) {
16910 var deferred = new Deferred(),
16911 counter = 0,
16912 results = isArray(promises) ? [] : {};
16913
16914 forEach(promises, function(promise, key) {
16915 counter++;
16916 when(promise).then(function(value) {
16917 results[key] = value;
16918 if (!(--counter)) deferred.resolve(results);
16919 }, function(reason) {
16920 deferred.reject(reason);
16921 });
16922 });
16923
16924 if (counter === 0) {
16925 deferred.resolve(results);
16926 }
16927
16928 return deferred.promise;
16929 }
16930
16931 /**
16932 * @ngdoc method

Callers

nothing calls this directly

Calls 3

isArrayFunction · 0.85
forEachFunction · 0.70
whenFunction · 0.70

Tested by

no test coverage detected