angular-q-extras
v1.1.1
Published
Angular $q decorator
Downloads
254
Readme
angular-q-extras
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