Reputation: 7980
I'm using Retrofit library on my Android app to make HTTP calls to an API.
I'm using the Callback
way to access the results, ie running it on async mode.
Now, some Retrofit
calls will depend on the result of previous Retrofit
calls, in other words, I can only call methodB()
when I've received the result from methodA()
.
I thought about implementing an IntentService
and call the Retrofit methods there but I don't find it very elegant to accomplish what I want.
Is there any elegant and better way to make this async calls run synchronized?
Upvotes: 2
Views: 937
Reputation: 7980
I ended up using Retrofit in sync mode and execute the sync calls on an IntentService
.
The other solution, as pointed out by njzk2 in the comments, could be calling async tasks on the callback
but that would lead to nested code which could make the code barely readable.
I'm still interested in a better approach than the IntentService
with Retrofit
in sync mode, if you have one feel free to share.
Upvotes: 3