CruelEngine
CruelEngine

Reputation: 2841

Angular 2 Rxjs Timeout

I've been trying to get timeout working with my http Get calls but the Http calls are never timed out until no response is sent from server . What am i doing wrong ?

return Observable.interval(30000).startWith(0).flatMap(()=>{
            return this.http.get(someUrl).timeout(3000)
                    .map(this.extractData)
                    .catch(this.handleError);
        });

I'm using rxjs-5.0.0-beta.12 in my application

Thanks in advance

Upvotes: 1

Views: 1587

Answers (1)

Muhammed Albarmavi
Muhammed Albarmavi

Reputation: 24424

Try delay operator to shift the emissions from an Observable forward in time by a particular amount.

 return Observable.interval(30000).startWith(0).flatMap(()=>{
                return this.http.get(someUrl).delay(3000)
                        .map(this.extractData)
                        .catch(this.handleError);
         });

Upvotes: 0

Related Questions