https://github.com/jutaz/angular-quasar
Enhanced angular $q on steroids
https://github.com/jutaz/angular-quasar
angular javascript promise-chain
Last synced: 6 months ago
JSON representation
Enhanced angular $q on steroids
- Host: GitHub
- URL: https://github.com/jutaz/angular-quasar
- Owner: jutaz
- License: apache-2.0
- Created: 2014-12-14T13:30:46.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-06-08T19:02:25.000Z (almost 8 years ago)
- Last Synced: 2024-11-10T03:28:06.872Z (over 1 year ago)
- Topics: angular, javascript, promise-chain
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
angular-quasar
==============
Enhanced angular $q on steroids.
## API
### .fcall
Allows to create new promise chain
```js
$q.fcall(function () {
// Do things
}).then(function () {
// More things
});
```
### .success
Passes `$http`\`s `.success` response down the chain.
```js
$q.fcall(function() {
$http.get('http://cutekittens.com/meow');
}).success(function (data, status, headers, config) {
// Oh, the hard work here!
});
```
### .error
Passes `$http`\`s `.error` response down the chain.
```js
$q.fcall(function() {
$http.get('http://cutekittens.com/meow');
}).error(function (data, status, headers, config) {
// Oh, error happened!
});
```
### .delay or .timeout
Integrates timeout right into promise chain!
```js
$q.fcall(function () {
// Whatever hard work here
}).delay(function () {
// Executed after 500ms
}, 500).then(function() {
// Executed normally
});
```
### .all
Removes need to do separate `return $q.all(Array)` call.
```js
$q.fcall(function () {
return [Promise, Promise, Promise];
}).all(function (resolved) {
// `resolved` contains resolved promises array
});
```
### .spread
Spreads array items as arguments.
```js
$q.fcall(function () {
return ['a', 'b', 'c'];
}).all(function (a, b, c) {
// `a`, `b`, `c` contain their respective values
});
```