dimanche 6 août 2017

Using javascript Promise asynchronously

Here's the problem - I call a function and that optionally displays a dialog multiple times and waits for the user to press OK. Then after that - I want to do something else.

I think the solution requires use of Promise. But the async nature of the dialog.alert() call, is throwing me off.

function a()
{
if ( condition_ok )
{
   // there could be multiple dialogs
   //
   for ( int i = 0; i < 2; ++i )
      dialog.alert("press ok").then ( ()=> { console.log("done"); } );
  }
}
a();
// call b() after all the dialogs have been closed in a()
b();

Aucun commentaire:

Enregistrer un commentaire