//Your feature request, I just find the randomness, for example
//The value of the default argument was framed for the 1st case, You could be checking
function someAsync(cur = 1){
return Promise.resolve(cur * Math.random());
}
//Runner function that will asynchronously-recursive perepisyvatsya
function run(next){
return someAsync(next).then(result => {
if(result < 0.1) { //Some condition that the latter result is obtained
return result;
}
return run(result); //Restart
});
}
run().then(result => console.log('Latest result:', result));
async function go(){
let p1 = promise1 await(...);
let p2 = await promise2(p1);
let p3 = await promise3(p2);
return p3;
}
go().then(response=>{
console.log(response); // <= p3
}).catch(console.error);
promise1
.then(response1=>{
return promise2(response1);
})
.then(response2=>{
return promise3(response2);
})
.then(response3=>{
console.log(response3) // <=your result
})
.catch(console.error);
const promise = (params) => new Promise((resolve, reject) => { ..... some code });
Find more questions by tags JavaScript
the number of promises in any case limited, and hence the reaction to every promise can be evaluated, and then take Redux and through state run chain of promises. In your case make the object States in the subscription stuff promises to respond to your work, and dispatchit in then all the promises condition and requirement what to do next. Relatively speaking you have a starter promise, who is in everything for your changes the state, that promis that fall under the task receives from the subscription information, and continues the chain. If laziness Mara with reduxa, you can have the same build using EventEmmiter - Roma2 commented on August 19th 19 at 23:32