I would like to returns an observable that return two values (in an array or dict) where one value is a conditional http request of the first.
Taking the example from https://coryrylan.com/blog/angular-multiple-http-requests-with-rxjs, I would like to modify the following:
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: 'app/app.component.html'
})
export class AppComponent {
homeworld: Observable<{}>;
constructor(private http: Http) { }
ngOnInit() {
this.homeworld = this.http.get('/api/people/1')
.map(res => res.json())
.mergeMap(character => this.http.get(character.homeworld))
}
}
So the observable will return both the homeworld and(!) the character.