I cant find a way to combine or chain a list of observables that it´s responses are prerequisites to other call that creates another Observable.
I´m using retrofit with observables.
My Service:
String url = "/geocode/json?sensor=false";
@GET(url)
Observable<GeocodeResult> getReverse(@Query("key") String gMapsKey,
@Query("latlng") LatLng origin);
And another service needs that GeocodeResult
@POST("/api/orders")
Observable<Order> createOrder(@Body GeocodeResult newOrder);
And I´m trying with:
// Prerequisite 1 Observable geocodeObservable = Address.get(...);
// Call createOrder after geocode is obtained? return Observable.combineLatest(geocodeObservable, geocode -> createOrder(geocode));
But it don´t work because combineLatest needs an object, not an observable but I need to return the observable.
With JoinObservable:
Pattern5<Geocode> pattern = JoinObservable.from(geocodeObservable)
Plan0<Observable<Order>> plan = pattern.then(Order::create);
return JoinObservable.when(plan).toObservable().toBlocking().single();
But it throws an NoSuchElementException exception. Why?
I do toBlocking().single() because I need the Observable and not the Observable<Observable<Order>> :(.
Or how can I do it?