I am making web api calls which don't return values and only their HTTP status code is of interest to me. But i want those calls to timeout after a specified time span.
Because i missed reading the doc, i used the timeout-operator on the web-call-observable like so:
this.someProvider.requestStatus(someValue)
.pipe(timeout(this.timeoutMilliseconds))
.subscribe(() => console.log("Success"),...)
The thing is, that i receive the successfull webcall within the subscriber function, but even after the timeout time span the call still fails, because the source observable did not return a value - i think.
Is there a way to do this with the rxjs operators when i don't get the HTTPResponse back and only the body - if any?
takeUntil
operator – C_Ogootimeout
will throw an error if the source Observable doesn't emit for a period of time. But if the source completes thentimeout
will stop. So it looks like your source Observablethis.someProvider.requestStatus()
doesn't complete. – martin