While migrating application from Angular 5 to Angular 6 getting below error,
Module '/node_modules/rxjs/observable/TimerObservable' has no exported member 'TimerObservable'.
Code:
import { Injectable } from '@angular/core';
import { TimerObservable } from 'rxjs/observable/TimerObservable';
import { Observable } from 'rxjs';
@Injectable()
export class TimerTestScv {
static fetchTimer(interval: number, initialDelay: number): Observable<number>
{
return TimerObservable.create(initialDelay, interval);
}
}
rxjs package used:
"rxjs": "^6.2.2",
From RxJS 6 onwards, TimerObservable has been replaced with timer. Use the following as a replacement:
import { timer } from 'rxjs';
// start at time 1s and tick every 2s
let myTimer = timer(1000, 2000);
const subscription = myTimer.subscribe(() => {
/* Do stuff here */
})
...
subscription.unsubscribe()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With