Skip to content

Instantly share code, notes, and snippets.

@panda4man
Forked from Aaronius/q-all-settled.js
Last active August 29, 2015 14:13
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 panda4man/ac61979ec0149c5cac04 to your computer and use it in GitHub Desktop.
Save panda4man/ac61979ec0149c5cac04 to your computer and use it in GitHub Desktop.
angular.module('qAllSettled', []).config(function($provide) {
$provide.decorator('$q', function($delegate) {
var $q = $delegate;
$q.allSettled = function(promises) {
return $q.all(promises.map(function(promise) {
return promise.then(function(value) {
return { state: 'fulfilled', value: value };
}, function(reason) {
return { state: 'rejected', reason: reason };
});
}));
};
return $q;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment