Mohamed
Mohamed

Reputation: 1271

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)->{

        });

Upvotes: 7

Views: 8875

Answers (2)

Eugene Loy
Eugene Loy

Reputation: 12416

There is a zip function variant that zips 3 sources.

Upvotes: 4

Mohamed
Mohamed

Reputation: 1271

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;
        });

Upvotes: 9

Related Questions