Starting from:
Don't promise what you can't deliver
You might assume that a promise in Javascript is based on this principle by ensuring that there will always be a ( expected? ) result.
Taking this code as an example:
var promesa = new Promise(
function(resolve, reject) {
alert('Hola mundo!');
}
);
promesa.then(
function(value) {
alert('Hola universo!');
}).then(
function(value) {
alert('Hola multiuniverso!');
});
A serial process is triggered until show alert('Hola multiuniverso!');
, which could also be done with nested Ajax Requests , which leads me to assume that there are also other advantages over a simple Ajax call.
The main questions would be (I know there are several and it is not so well seen within SOes, but with the explanation of what a promise is, several of them are resolved):
- What is a promise?
Promise
a plugin , a standard or a design pattern?- Is ajax a promise type?
- Can promises be synchronous and asynchronous calls?