Combine a list of Observables and wait until all completed

前端 未结 8 1060
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 06:35

TL;DR How to convert Task.whenAll(List) into RxJava?

My existing code uses Bolts to build up a list of asynchr

相关标签:
8条回答
  • 2020-12-04 07:06

    You probably looked at the zip operator that works with 2 Observables.

    There is also the static method Observable.zip. It has one form which should be useful for you:

    zip(java.lang.Iterable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction)
    

    You can check out the javadoc for more.

    0 讨论(0)
  • 2020-12-04 07:07

    If you use Project Reactor, you can use Mono.when.

    Mono.when(publisher1, publisher2)
    .map(i-> {
        System.out.println("everything is done!");
        return i;
    }).block()
    
    0 讨论(0)
提交回复
热议问题