Фильтровать массив по некоторым свойствам в другом массиве - PullRequest
0 голосов
/ 06 мая 2019

Мне нужно подождать, пока конкретный результат снова и снова консультируется с одной и той же конечной точкой, пока результат конечной точки не вернет конкретное значение. Я иду по хорошему пути или есть что-то другое, что я могу сделать? Идея состоит в том, чтобы пользователь ждал с занятым загрузчиком, пока процесс завершается. Спасибо

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;
};
...