fetchResult(query) // возвращает промис
.then(function(result) {
return processResult(result);
})
.then(function(processedResult) {
console.log('processed result', processedResult);
});
var promise = new Promise(function(resolve, reject) {
console.log('I\'m promise');
resolve('resolve');
});
for (var i=0; i<10000; i++) {
console.log(1);
}
promise.then( function (result) {
console.log(result);
return 'f1';
});
promise.then( function (result) {
console.log(result);
return 'f2';
});
I'm promise
(10000 раз) 1
resolve
resolve