One observable two observers

687 views Asked by At

Is there any object in RxJava, other than ConnectableObservable<> that enables to have multiple subscriptions on a Observable? For example a particular Subject?

E.g. for the given Subject below:

private PublishSubject<Location> locationSubject = PublishSubject.create();

I need to have multiple subscriptions:

locationSubject
    .{several filtering, throttling functions here}
    .subscribe(a -> doSomething(a));

locationSubject
    .{several other filtering, throttling functions here}
    .subscribe(a -> doSomethingElse(a));

So in the above case the second subscription will overwrite the first one. Who can I keep both subscriptions alive?

1

There are 1 answers

0
Diolor On BEST ANSWER

For the sake of completeness: PublishSubject can transmit events to more than one subscribers.