我有一个角度函数,它返回状态为“继续”或“完成”的数据集。我想继续拨打电话,直到状态返回“完成”,但最多只能持续一分钟。我怎样才能在角度实现这一点
public getLeadsResponse(key: any) {
this._service.getLeadsData(key).subscribe((response: any) => {
if (response) {
if (response.payload.status == "running") {
// here if i repeate this function it will start an infinite loop if status is always "running"
this.getLeadsResponse(key);
}
else if (response.payload.status == "finished") {
this.items = res.payload.result;
}
}
})
}