I am trying to filter the set of emissions before flatmapping to an API call to prevent overloading the server, but I'd like the subscriber to get an onNext for each original event. I debounce the original observable, and flatmap it to the API call (calling map on the inner observable to combine the input and output into a pair since the subscriber needs both. Where I am getting stuck is on how to propagate to the subscriber the emissions that were filtered out before the flatmap.
Is there a idiomatic way of doing what I am trying to do? combineLatest() seems similar to what I am trying to do, but I am not clear on how I would get the two observables to feed into it. Does this look like a reasonable approach?
Observable<Location> initialObservable = getLocationObservable().share();
Observable<ApiResult> apiResultObservable = initialObservable
.debounce(1, TimeUnit.MINUTES)
.flatmap(l -> api.call(l.x, l.y));