How to subscribe on result of flatMap?
timer(0, 2000)
.pipe(
flatMap(() => this.scannerService.scan(this.scanType)),
takeWhile(res => res.errorDesc !== "SUCCESS")
)
.subscribe((res: IScanResponse) => {
});
I tried do use .subscribe()
after pipe
. But I get error as:
You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
My remote function is:
public scan(scanType: string): Observable<any> {}
My imports are:
import { timer } from "rxjs";
import { takeWhile } from "rxjs/operators";
import { ScannerService } from "src/app/api/ScannerService";
import { flatMap } from "rxjs/operators";