ngAfterViewInit(){
Observable.interval(3000).timeInterval().subscribe()=>{};
}
Trying to invoke the Observable.interval() method it is
import { Observable } from 'rxjs';
import { interval } from 'rxjs';
import { takeWhile } from 'rxjs/operators';
// here 20 (secs) is a reference till when it will get completed
interval(1000).pipe(takeWhile(value => value < 20)).subscribe(
(value: number) => {
this.secondes = value;
},
(error: any) => {
console.log('error');
},
() => {
console.log('observable completed !');
}
);
This is a answer to how to unsubscribe.