I have implemented http pooling in Angular app with IntervalObservable and startWith to start instantly. I wanted to know does IntervalObservable wait until initial/previous call finished streaming data? Is there a better way to implement data poolingin Angular app.
Ex from service.ts
getRecordsList() {
return IntervalObservable
.create(15000)
.startWith(0)
.flatMap((r) => this.http
.post(`http://services.com/restful/recordService/getRecordsList`, body, {
headers: new HttpHeaders().set('Content-Type', 'application/json')
}))
.shareReplay()
.catch(this.handleError);
}
Ex from component.ts
ngOnInit() {
this.service.getRecordsList()
.subscribe(
(recordList) => {
this.recordResponse = recordList;
},
error => { console.log },
() => console.log("HTTP Observable getRecordsList() completed...")
);
}
I have used Angular httClient and I hope this doesn't matter anyhow.