I have a situation where I want to use
combineLatest (actually
withLatestFrom) and filter some of the combinations.
Let's say I have Observable<Temperature> and Observable<Boolean>. I would like to use something like combineLatest to only emit Temperature when the Boolean is true. I'd rather not have to use an intermediary object like Pair<Temperature, Boolean>.
i.e., is there a better way than this:
Observable<Temperature> observableTemperature = getTemp();
Observable<Boolean> observableBoolean = getTempPrefs();
Observable
.combineLatest(observableTemperature, observableBoolean, (Func2) (thing, aBoolean) -> {
return new Pair<Thing, Boolean>(thing, aBoolean);
})
.filter((Func1) (thingBooleanPair) -> {
return thingBooleanPair.second;
})
.map((Func1) (thingBooleanPair) -> {
return thingBooleanPair.first;
});