Что-то типа того?
const returnTrue = (arg) => {
setTimeout(console.log(`First function: - I\'m done. The argument is ${arg}`), 2000);
return [true, arg];
};
const mutationObserver = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('First promise done');
}, 1500);
});
const anotherPromise = args => {
return new Promise((resolve, reject) =>
setTimeout(()=> {
resolve(`Second promise done with ${args}`);
}, 1500));
};
mutationObserver
.then(result => {
const arr = returnTrue('some args')
if (arr[0]) {
console.log(result );
return anotherPromise(arr[1]);
}
})
.then(result => {
console.log(result);
});