I've got a TypeScript function in my Angular 2 app that returns an Observable, to push web API data back to the consumer, something like this:
public getApiData(): Observable {
let readySource = Observable.from('no', 'no', 'ready');
let dataSource = http.get('api/getData');
// ... magic here
return chainedObservable;
}
However, rather than returning the http.get
Observable as normal, I need to chain this HTTP call to another readySource
Observable that indicates whether the API is ready to call (it actually checks whether a background data sync job has finished).
How can I chain these two Observables together, so the HTTP call is only invoked once the readySource
pushes a particular value, e.g. "ready"?
(Note that vanilla flatMap/selectMany doesn't quite meet the requirement here, because I need to wait until the first Observable pushes a specific value before invoking the second.)