Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niqdev/angular-q-extras
Provides the missing angular $q.allSettled
https://github.com/niqdev/angular-q-extras
allsettled angular promise
Last synced: 8 days ago
JSON representation
Provides the missing angular $q.allSettled
- Host: GitHub
- URL: https://github.com/niqdev/angular-q-extras
- Owner: niqdev
- License: mit
- Created: 2015-12-21T11:39:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-28T19:18:42.000Z (about 6 years ago)
- Last Synced: 2024-10-08T01:33:23.934Z (about 1 month ago)
- Topics: allsettled, angular, promise
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angular-q-extras
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![devDependency Status][dependency-image]][dependency-url]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
``
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](https://www.npmjs.com/package/@types/angular-q-extras).
### Example
```javascript
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
* [nvm](https://github.com/creationix/nvm)
```
# setup
npm installnpm start
npm test# publish
npm login
npm publish
```[npm-image]: https://img.shields.io/npm/v/angular-q-extras.svg
[npm-url]: https://www.npmjs.com/package/angular-q-extras
[travis-image]: https://travis-ci.org/niqdev/angular-q-extras.svg?branch=master
[travis-url]: https://travis-ci.org/niqdev/angular-q-extras
[dependency-image]: https://david-dm.org/niqdev/angular-q-extras/dev-status.svg
[dependency-url]: https://david-dm.org/niqdev/angular-q-extras#info=devDependencies