New to Web-dev and Angular. Here is my current code. Right now, all it does is calling a http requests every 2seconds and console log the message. What I want is if the message matches to a string “5”, let it unsubscribe. Also, how do i make this as non-nested subscribe? (is nested subcribe a bad practice?). Currently, i’m using Angular 5 and rxjs 5.
public checkProgress() {
Observable
.interval(2000)
.subscribe(
x => {
this.myService.getStatus()
.subscribe( data => console.log(data));
}
);
}
Also, if a user navigate to a different component, how do I unsubscribe it? ngOnDestroy?