I have a service that get data from a server every 3 seconds. Sometimes the server is very slow and many responses comes after 5 or 6 seconds. When this happen ,my service starts to cancel each request instead of waiting the pending one. How can I prevent this?
public getCallDiagnostic():Observable<IRespWidgets>{
let body = JSON.stringify({manager:"CallDiagnosticServiceManager",
action:"GetCallDiagnostic",
WEB_USER_TOKEN:this._authenticationService.getUserToken()});
let options = new RequestOptions({headers: new Headers({'Content-Type': 'application/json'})});
return Observable.timer(0,3000)
.switchMap(()=>this._http.post(this._apiUrl,body,options))
.map(res => <IRespWidgets>res.json().data)
.catch(this.handleError);
}