Promise
- Native implementation of promises. Yay!
- Promises/A+ spec compliant
var promise = new Promise(function(resolve, reject) {
// Do something asynchronous and call resolve with the
// result or reject with the error
});
promise.then(function(result) {
// Use the result of the async call
}, function(error) {
// Process the error
});
var allPromise = Promise.all([getLocation, getTemperature]);
allPromise.then(function([location, temperature]) {
console.log('The location is ', location,
'and the temperature is', temperature);
}, function(error) {
// Process the error
});
var racePromise = Promise.race([getGoogleAds, getYahooAds, getBindAds]);
racePromise.then(function(ads) {
page.addAds(ads);
});
⛏ ES6 Katas: Operador Spread
Hacer las siguientes katas: