RXJava2: correct pattern to chain retrofit requests

后端 未结 2 1059
灰色年华
灰色年华 2021-01-04 12:41

I am relatively new to RXJava in general (really only started using it with RXJava2), and most documentation I can find tends to be RXJava1; I can usually translate between

2条回答
  •  不知归路
    2021-01-04 13:26

    Does this not work for you?

    retrofitService
    .getSomething()
    .flatMap(firstResponse -> retrofitService.getSecondResponse(firstResponse.id))
    .doOnNext(secondResponse -> {/* both requests succeeded */})
    /* do more stuff with the response, or just subscribe */
    

提交回复
热议问题