I have an API method which returns a promise resolving with an observable of Item
s. Using the means of RxJS how can I turn this promise into the observable of Item
s? In the language of code:
get items$(): Observable<Item> {
const sourcePromise: Promise<Observable<Item>> = apiService.getItemsObservable();
const sourceObservable: Observable<Observable<Item>> = from(sourcePromise);
// ...
}
CodePudding user response:
You can solve this by using mergeMap. This will remove one layer of observables:
const levelDown$ = SourceObservable.pipe(
mergeMap(val=>val)
);