I'd like to see an Android java example of how to sequence a chain of async (= nonblocking) RESTful Volley requests.
Is this what RxAndroid is used for?
- If so, I'd like to see the example using RxAndroid.
- If not, I'd still like to see a good example w/out diving into CALLBACK HELL!
I tried to do so but ended up in CBHell: Need to send multiple Volley Requests - in a sequence
I want my result from my 1st request to be used in the 2nd request. Then the result from the 2nd request I want used in the 3rd request. Please, how do I chain such Volley requests?
You could use Rx to chain multiple requests by using the
flatMap
method.flatMap
requires you to return anotherObservable
of the type of your chosing thus allowing you do something async with another type.All of the examples below are made with the new rx v2. But all methods and mechanics also apply to v1
Example:
This is the
MyVolleyApi
dummy class:This could apply to anything, it's not volely specific at all