ferpar1988
ferpar1988

Reputation: 606

Ensuring all subscriptions are done before calling connect on a ConnectableObservable

I have a ConnectableObservable and multiple subscribers. And subscriptions are happen in different threads by using subscribeOn operator.

Problem is that I want to call connect operator when all subscriptions are done because I don't want any subscribers miss any packets.

But I cannot make sure if all subscribers have subscribed the observable because it happens on different threads.

Also I don't want to use replay operator. There is no reason to cache all packets just because of async subscriptions.

Upvotes: 1

Views: 53

Answers (1)

akarnokd
akarnokd

Reputation: 69997

If you know the exact number of Subscribers and the only action you want is to connect when all of them are ready then use autoConnect(int).

Upvotes: 0

Related Questions