I have some promises, for example:
promise1 = function() { return new Promise(a,b){} ....}
promise2 = function() { return new Promise(a,b){} ....}
promise3 = function() { return new Promise(a,b){} ....}
promise4 = function() { return new Promise(a,b){} ....}
It is possible to create other Promises by nesting these promises (1,2,3,4), for example:
promiseX = function() {
return new Promise(function() {
promise1().then(promise2)...
})
}
promiseY = function() {
return new Promise(function() {
promise3().then(promise4).....
})
}
To then use the last two created:
promiseX().then(promiseY).then(function().....)
Is this correct to do? What would be the correct way to do it in any case?