1.1.1 • Published 6 years ago

angular-q-extras v1.1.1

Weekly downloads
190
License
MIT
Repository
github
Last release
6 years ago

angular-q-extras

NPM version Build Status devDependency Status

Adds $q.allSettled to angular $q.

The $q.all function returns a promise for an array of values. When this promise is fulfilled, the array contains the fulfillment values of the original promises, in the same order as those promises. If one of the given promises is rejected, the returned promise is immediately rejected, not waiting for the rest of the batch. If you want to wait for all of the promises to either be fulfilled or rejected, you can use $q.allSettled.

Setup

Install

bower install angular-q-extras --save
npm install angular-q-extras --save

Require it into your application

<script src="path/to/angular-q-extras.min.js"></script>

Add the module as a dependency to your application

angular.module('yourApplication', ['angular-q-extras'])

Types

Typescript definitions are available on NPM : @types/angular-q-extras.

Example

var promises = [
  $q.when('SUCCESS_0');
  $q.reject('FAIL_1');
  $q.when('SUCCESS_2');
];

$q.allSettled(promises)
  .then(function (data) {
    expect(data).toBeArrayOfSize(3);

    expect($q.isFulfilledState(data[0])).toBeTrue();
    expect(data[0].value).toBe('SUCCESS_0');
    
    expect($q.isRejectedState(data[1])).toBeTrue();
    expect(data[1].reason).toBe('FAIL_1');
    
    expect($q.isFulfilledState(data[2])).toBeTrue();
    expect(data[2].value).toBe('SUCCESS_2');
  });

Development

# setup
npm install

npm start
npm test

# publish
npm login
npm publish
1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

8 years ago

0.1.9

8 years ago

0.2.0

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago