I played around with angular2 and got stuck after a while.
Using http.get
works fine for a single request, but I want to poll live-data every 4 seconds,
You can try using interval if that is more convenient. Calling subscribe
gives you Subscription
that lets you cancel the polling after sometime.
let observer = Observable.interval(1000 * 4);
let subscription = observer.subsscribe(x => {
this._http.get(this._url)
.share()
.map(this.extractData)
.catch(this.handleError)
});
....
// if you don't require to poll anymore..
subscription.unsubscribe();