I have a method that calls three(foo1(), foo2(), foo3()) api method inside it and each method is dependant on another method's response. I want to call foo1() and when it get response from api then call the foo2() and so on. I am eleborating the process below :
public class Order{
private String mResponse1 = "";
private String mResponse2 = "";
private String mResponse3 = "";
public boolean CreateOrder(String param1, String param2, String param3)
{
foo1(param1);
// Wait until foo1() get response
if(!mResponse1.IsEmpty())
{
//There is some line of code here then call below method.
foo2(param2);
}
// Wait until foo2() get response
if( !mResponse2.IsEmpty())
{
//There is some line of code here then call below method.
foo3(param3); }
//There is some line of code here .
return true;
} private void foo1(String param1)
{
----
----
mResponse1 = //Set api response
}
private void foo2(String param2)
{
----
----
mResponse2 = //Set api response
}
private void foo3(String param3)
{
----
----
mResponse3 = //Set api response
}
Now how to acheive the above senario using retrofit asynchronous calling. I can't break method CreateOrder() into three.

siri priyaPosted Dec 18, 2018, 5:45 AM
Your question has nothing to do with Retrofit, this is a general async coding question about composing multiple async calls. There's three basic answers:
Use synchronous calls and go async at a higher level.
Use the callback from method 1 to trigger method 2
Use RxJava for higher-order composing of streams. This would allow combing the result of the first API call with waiting for the loop in order to trigger the second API call.
tableau course in BTM
best tableau training in BTM
tableau training in BTM
tableau training in BTM
tableau certification in btm
tableau training institutes in btm
Laxmidhar SahooPosted Sep 29, 2018, 8:12 AM