Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Zip more than 2 Observables using RxJava 2.x?

I'm using RxJava 2.x, and have 3 observables (if important, specifically publish subjects).

I like to run them all once, and get results once. I was using Observable.zip() operator for this kind of processes. However It looks like Zip operator doesn't support more than 2 observables.

Is there other operator to combine more than 3 observables just like zip?

Observable.zip(
        getData(),
        getOtherData(),
        getTemplate(),
        (o1,o2,o3)->{

        });
like image 953
Mohamed Avatar asked Sep 13 '17 17:09

Mohamed


2 Answers

Actually,

It supports, I didn't return value, and IDE's error message was misleading.

Observable.zip(
        getData(),
        getOtherData(),
        getTemplate(),
        (o1,o2,o3)->{
            return null;
        });
like image 147
Mohamed Avatar answered Sep 22 '22 14:09

Mohamed


There is a zip function variant that zips 3 sources.

like image 22
Eugene Loy Avatar answered Sep 20 '22 14:09

Eugene Loy