I'm trying to find a proper RxJava 2 operator for my specific need. I have 2 server requests.
val singletonOne = repository.loadData(requestOne) // Returns Single
val singletonTwo = repository.loadData(requestTwo) // Returns Single
val combinedSingle = Single.zip(singletonOne, singletonTwo) { responseOne: MyResponse, responseTwo: MyResponse
CombinedResponse(responseOne, responseTwo)
}
Then I'm subscribing to my combined Single and can handle 2 responses extremely racting them from CombinedResponse.
RxUtil(schedulers).observe(combinedSingle).subscribe(combinedResponse -> {
view.updateSmthOne(combinedResponse.firstResponse.data)
view.updateSmthTwo(combinedResponse.secondResponse.data)
}, {/*Handle error*/})
Everything is fine wit this approach. But now I need to add one small change. I need to get one field from the 1st response use it to update one field of the 2d request and as a result I should get the same CombinedSingle. I went through RxJava 2 docs and could not find proper operator which could solve my problem.
Note
Yes, I can subscribe to the 1st single, get it's result and on onSuccess(...) make 2nd server request with updated field. That works, but I'm looking for better solutions with RxJava.
Thanks in advance.