asynchronous - While loops using Await Async. -
this javascript function seems use while loop in asynchronous way. correct way use while loops asynchronous conditions?
var boo; var foo = await getbar(i) while(foo) { boo = await getbar3(i) if (boo) { // } foo = await getbar(i) i++ } what think this:
var boo; var foo; getbar(i).then( (a) => { foo = a; if(foo) { getbar3(i).then( (a) => { boo = if(boo) { //something i++; getbar(i).then( (a} => { repeat itself...} } } } }) if that's totally false show way async await + while loop?
thanks!!
is correct way use while loops asynchronous conditions?
yes. async functions suspend execution on every await until respective promises fulfills, , control structures continue work before.
Comments
Post a Comment