Я так долго пытался решить эту проблему, любая помощь очень ценится. У нас есть метод, который разрешает токен в обещании. После выполнения обещания токен необходимо добавить в заголовки и отправить запрос на получение. Код выглядит следующим образом:
// actually this returns Observable<Observable<T>>
// but this is how it should have return type, only Observable<T>
function get<T>(uri): Observable<T> {
// create wrapper observable
const ob = new Observable<Observable<T>>(s => {
const promise = getPromiseOperation();
promise.then(y => {
const h = headers.set('Authorization', y);
const client = this.httpClient.get<T>(url, { headers: h });
// now next the actual observable
s.next(client);
s.complete();
});
});
return ob;
}
// consumer
get<Apple>().subscribe(x => x.subscribe(y => y));
// How I Actually want to consume is
get<Apple>().subscribe(x => x)
// I also would like to support pipe rxjs operators on the result
get<Apple>().pipe(map(x => x)).subscribe(x => x)
Любая помощь с благодарностью. Это как-то связано с mergeMaps в Rx js?