Property interval does not exist in the type observable

前端 未结 4 659
你的背包
你的背包 2020-12-09 08:42
ngAfterViewInit(){
     Observable.interval(3000).timeInterval().subscribe()=>{};    
}

Trying to invoke the Observable.interval() method it is

4条回答
  •  囚心锁ツ
    2020-12-09 09:29

    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.

提交回复
热议问题