I am trying to make a simple polling service using rxjs and angular 7 and am running into a recurring issue that my requests are only actually being fired once but the interval completes successfully with no errors.
My service component looks like this:
import { HttpClient, HttpHeaders, HttpRequest } from '@angular/common/http';
import { interval, Subject } from 'rxjs/index';
import { exhaustMap } from 'rxjs/internal/operators';
constructor( private httpClient: HttpClient ) {
}
getPing() {
const req = new HttpRequest('GET', this.getUrl, {responseType: 'blob', headers: new HttpHeaders(), reportProgress: true});
interval(1000)
.pipe(take(4))
.pipe(exhaustMap(()=> this.httpClient.request(req)))
.subscribe(data => console.log(data));
}
I have console logs showing that the interval occurs and completes after 4 intervals but only the first request is called according to the network tab.
If I use fetch instead of http client or change the interval to a loop the service behaves as expected however I would prefer to not use those approaches. Does anybody know what I'm missing?
I am using angular 7.0.0 and rxjs 6.2.2 Console logs Network Tab