I have a use case as follows:
How to reflect this fact that the video is now available on the Angular side?
I'm doing something similar to the following and it is working fine, but I'm not so sure if the error-case is being handled correctly? Should I be doing anything more?
startLp(): Observable<any> {
return this.http
.get("/getvideostatus?video-id=blah", { headers: this.headers })
.map(res => {
return res.json();
})
.catch((error: any) => Observable.throw(error.json().error || 'Server error'));
}
This is just a regular http request, the only difference is the server not returning the response immediately.
Would this constitute a valid http long poll?
This is what I ended up doing:
public startLp(): Observable<any> {
let that = this;
let doLp = function(): Observable<any> {
return that.http
.get("/getvideostatus?video-id=blah", { headers: that.headers })
.map(res => {
return res.json().data
})
.catch((error: any) => {
return doLp();
});
};
return doLp();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.