我正在使用 ember-concurrency ,我必须每 10 秒调用一次 API 并更新我的应用程序安装阶段的设置状态。如果有错误,那么我需要超时值为 1 秒,而不是默认值为 10 秒。似乎每次超时值仅为 10 秒,即使出现错误,用户在屏幕上停留 10 秒,然后看到错误模式。谁能告诉什么是可能的解决方案?或者我做错了什么?
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();
}