Skip to content

Instantly share code, notes, and snippets.

@Aaronius
Last active March 29, 2021 09:12

Revisions

  1. Aaronius revised this gist Sep 19, 2014. 1 changed file with 14 additions and 12 deletions.
    26 changes: 14 additions & 12 deletions q-all-settled.js
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    $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;
    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;
    });
    });
  2. Aaronius renamed this gist Sep 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. Aaronius renamed this gist Sep 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. Aaronius created this gist Sep 19, 2014.
    13 changes: 13 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    $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;
    });