How to combine multiple RxJava chains non-blocking in error case

后端 未结 5 1450
旧巷少年郎
旧巷少年郎 2020-12-15 10:19

My requirements:

  • N Retrofit calls in parallel
  • Wait for all calls to finish (success or failure)
  • If k (0<= k < N) calls fail, they sho
5条回答
  •  暖寄归人
    2020-12-15 11:13

    1. For multiple parallel calls in Retrofit, we need to set it up from OkHttp layer when initializing Retrofit. Please check this.
    2. If you use combineLatest or zip operators in this case (for Retrofit call), each call only emits an item. So, both of operators will wait for all calls to finish. So, we do not need to worry about this point. For more information, check out combineLatest and zip.
    3. If you meant 1 call fail about the RxJava stream error, this error will be thrown, none of combined item will be emitted. But 1 call fail is http request fail, the stream always emit one item when 3 calls finish. we can not use combineLast or zip operator here.

提交回复
热议问题