vendredi 17 août 2018

ember concurrency, how to set timout value based on conditions

I am using ember-concurrency where I have to make API calls every 10 seconds and update the setup status for my application install phase. If there is an error, then I need the timeout value to be 1 seconds instead if default value of 10 seconds. Seems like every time timeout value is 10 seconds only and even with an error, user is on the screen for 10 seconds and then sees an error modal. Can anyone tell what can be a possible solution? or what I am doing wrong?

induceWait: task(function*() {
  while (continue) {
   // make the api call here
   //if error in any evaluating conditons, set timeout value to be 1 seconds, else 10 seconds
   this.get('store').findAll('status').then((response) => {
     if (response.flag) {
        this.set('timeout', 10000);
     } else {
        this.set('timeout', 1000);
      }
   }, (error) => {

   });
   yield timeout(this.get('timeout');
   this.get('induceWait').perform();
}




Aucun commentaire:

Enregistrer un commentaire