按另一个数组中的某些属性过滤一个数组

时间:2019-05-06 12:03:03

标签: javascript timeout wait

我需要等待特定结果一遍又一遍地咨询同一端点,直到端点的结果返回特定值。我会选择好的方法还是可以做些别的事情?想法是,用户等待繁忙的装载机同时完成过程。谢谢

that.genereateJournalEntrieReport = function genereateJournalEntrieReport() {
 that.generateAndGetOMSID()
 .then(Report.reportJournalEntries.bind(that.year, that.month)) // ==> call 
  compilance with the oms operationId
 .then(Report.getOMSStatus) // get OMS status for operationId
 .then(that.evaluateOMSStatus) // evaluate OMS status and start to iterate until the job succeed
 .then(that.exportDataDownloadedToExcel)
 .catch(that.onError);

that.evaluateOMSStatus = function evaluateOMSStatus(response) {
 var deferred = $q.defer();
 switch (response.status) {
  case 'resolve': {
   deferred.resolve(response);
  }
  case 'error' || 'timeout' || 'failed': {
   deferred.reject(response);
  }
  default: {
   return Report.getOMSStatus(response.operationId)
      .then(that.evaluateOMSStatus);
  }
 }
 return deferred.promise;
};

0 个答案:

没有答案
相关问题