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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -