2016-08-29 2 views
0

을 사용하여 추가 장착 된 두 번째 끝점 호출 조건이 참이면 두 번째 호출을 끝점에 연결하려고하는데이 조건은 첫 번째 끝점 호출과 관련이 없습니다.조건이 참이면 RxJava

retrofitService.endpoint1() 
      .subscribe(response1 -> { 
        doStuff(response1); 
        if (condition){ 
         retrofitService.endpoint2() 
           .subscribe(response2 -> { 
           doStuff(response2) 
           }); 
        } 
       }); 

운영자가 나는 경우의 첫 번째 호출 가입자에서 두 번째로 호출 일을 방지하기 위해 사용할 수 있습니까 : 이것은 내가 지금까지 얼마나입니까?

답변

0

나는 당신의 의견에 대해 필터 http://reactivex.io/documentation/operators/filter.html

환호 보이 테크

을 사용

그런 식으로 할 : 두 번째 API 호출에서 결과를 사용하는 경우

retrofitService.endpoint1() 
    .filter(condition) 
    .subscribe(response1 -> { 
        retrofitService.endpoint2() 
         .subscribe(response2 -> { 
            doStuff(response2) 
               }); 

       }); 
+0

이 작동합니다 첫 번째 것이지만, 첫 번째 것이 무엇을 반환했는지에 관계없이 두 번째를 호출하려고 시도했지만 부울 – iluretar

관련 문제