I have a class with an Observable in it. I want to create second Observable that will be generated by the value of the first observable and the response of the HTTP-request. I want to regenerate value of the second Observalble on every change in the first Observable.
I need to get Observable<number> in returning type. I tried to do it with map, switchMap, fromPromise. In some cases the returning type of the second Observable became Observable<Observable<number>> (when I used map), in some cases typescript hinted me that the returning type should be ObservableInput<number>.
Help me to understand how to correctly use promises in rxjs!
function someHTTPRequest(): Promise<number> {
}
class MyClass {
firstObs$: Observable<Array<string>>;
get secondObs$(): Observable<number> {
return firstObs$.pipe(
switchMap((items: Array<string>) => fromPromise(someHTTPRequest(items)))
)
}
}