, , .
. . , , , . , , , , : 1. 2. . 3.
1. . Promises javascript. , . - . -
aAsync()
.then(bAsync)
.then(cAsync)
.done(finish);
, ,
aAsync(function(){
return bAsync(function(){
return cAsync(function(){
finish()
})
})
});
2. . , , . . : ? , , :
api()
.then(function(result) {
return api2();
})
.then(function(result2){
return api3();
})
.then(function(result3){
})
.catch(function(error) {
});
api()
.then(function(result){
return api2(); })
.then(function(result2){
return api3(); })
.then(function(result3){
})
.catch(function(error) {
})
.then(function() {
});
3. : , 3 api, api2, api3 (, AJAX), ? - . , ES6, :
Promise.all([api(), api2(), api3()])
.then(function(result) {
})
.catch(function(error) {
});
, .
source
share