In RxJava, how to pass a variable along when chaining observables?

Here is my use case: I have a View that is a secondary index and return documents keys, I do a ViewQuery(secondary_index) and flatmap the result to a function that fetch the actual documents. I want to be able to access the value of “secondary_index” down the chain for logging & error handling.

@ldoguin ok thanks, I believe using a Tuple is similar to the stackoverflow solution that uses Pair.

I imagine a value object is a custom object that I’d design to contain all the values I want to pass along.

@daschl I didn’t think about an inner observable, it feels less readable than chaining stuff but I see it can work. Maybe I’ll try that.