Thanh Le
Thanh Le

Reputation: 1389

Rxjava minimum time execution?

I have an Observable A and an Observable B. Now I have to wait those Observables finish or at least 30 seconds. How I can achieve this on RxJava?

Thanks for any suggestion!

Upvotes: 2

Views: 1188

Answers (1)

Dave Moten
Dave Moten

Reputation: 12087

You haven't said what you want to do with the emissions of a and b apart from wait for completion to finish but you could do this:

Observable.merge(
    Observable.timer(30, TimeUnit.SECONDS)
        .ignoreElements().cast(Object.class),
    a.ignoreElements().cast(Object.class),
    b.ignoreElements().cast(Object.class));

Upvotes: 3

Related Questions