Skip to content

Promise polyfill for angular. Use angular $q as global Promise polyfill

Notifications You must be signed in to change notification settings

wilix-team/angular-promise-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

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/8f04507acd014b57b95a) Thanks man! =)

About

Promise polyfill for angular. Use angular $q as global Promise polyfill

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published