Need help with Angular 7 function call timing
checkData(): Observable<string> {
return this.http.get('')
.pipe(
map(res => {
let result;
result = {
packageNumber: this.packageNumber,
};
return result;
})
);
}
In my component, I'm attempting to auto-call the function:
private killTrigger: Subject<void> = new Subject();
private fetchData$: Observable<string> = this.packageService.checkData();
private refreshInterval$: Observable<string> = timer(0, 1000)
.pipe(
takeUntil(this.killTrigger),
switchMap(() => this.fetchData$),
catchError(error => of('Error'))
);
Any suggestions on how to get it working?