Reputation: 7247
In RxJava1 flatmap
had a overloaded method that allowed you to retain source values and pass it down the stream.
I've gained this knowledge from the following blog post
However, moving to RxJava2, I cannot seem to find it. I checked the changes from Rx1 and Rx2 and it is not listed. I would like to know if it exists still but I am perhaps not looking in the right place.
I am using a Single
by the way.
Upvotes: 1
Views: 919
Reputation: 69997
I don't think Single
ever supported this operator and the Observable
/Flowable
operators are still there. You can accomplish this behavior by mapping the result of the inner source:
source.flatMap(originalValue ->
createInnerSource(originalValue)
.map(innerValue -> process(originalValue, innerValue))
)
The lambda of the map
will capture the originalValue
for you.
Upvotes: 5