Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wilix-team/angular-promise-polyfill
Promise polyfill for angular. Use angular $q as global Promise polyfill
https://github.com/wilix-team/angular-promise-polyfill
Last synced: 2 months ago
JSON representation
Promise polyfill for angular. Use angular $q as global Promise polyfill
- Host: GitHub
- URL: https://github.com/wilix-team/angular-promise-polyfill
- Owner: wilix-team
- Created: 2016-09-23T11:47:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-15T18:48:19.000Z (over 7 years ago)
- Last Synced: 2024-01-29T06:16:40.235Z (12 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-promise-polyfill
This module provide Promise support via using angular $q service.
### Instructions
```npm install angular-promise-polyfill```
Then just include this module to your project and add to main Angular app dependencies.
```javascript
require('angular-promise-polyfill');let app = angular.module('myApp', ['angular-promise-polyfill', ...]);
// Now you can use Promise anywhere
var promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('second');
}, 2000);
});var promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('first');
}, 1000);
});Promise.race([promise1, promise2])
.then((result) => {
//Logs 'first'
console.log(result);
})
```## Big thanks
Original answer from [Rob / robianmcd](https://gist.github.com/robianmcd) (https://gist.github.com/robianmcd/8f04507acd014b57b95a)
Thanks man! =)