I have to implement pooling in my case, but I have some problem with correct implement all my condition.
So first, I have to call to one endpoint, and after it return success, call another endpoint until it returns correct response (It always return success /200/, but for me most important is response, so if the response will be {state: 'ready'} or if time will pass (20 sec), I should stop call api.
executeTest$(testCode: string, name: string): Observable<Test> {
let requestDelay = 500;
return this.testService.start({
body: {
code: {value: testCode},
name
}
}).pipe(
switchMap(body => {
return this.testStatus(body.name).pipe(
delay(500),
// and here I have problem to implement logic:
repeat this http until condition is met, so until response will be {state: 'ready'}
I see that repeat when is deprecated and retry when is suitable for errors.
timeout(20000)
);
})
);
}
private testStatus(testId: string): Observable<Test> {
return this.http.get(apiUrl)
}