一个可观察的两个观察者
One observable two observers
除了 ConnectableObservable<>
之外,RxJava 中是否有任何对象允许对一个 Observable 进行多个订阅?例如一个特定的主题?
例如对于下面给定的主题:
private PublishSubject<Location> locationSubject = PublishSubject.create();
我需要多个订阅:
locationSubject
.{several filtering, throttling functions here}
.subscribe(a -> doSomething(a));
locationSubject
.{several other filtering, throttling functions here}
.subscribe(a -> doSomethingElse(a));
因此在上述情况下,第二个订阅将覆盖第一个。谁可以让两个订阅保持有效?
为了完整起见:PublishSubject
可以将事件传输给多个订阅者。
除了 ConnectableObservable<>
之外,RxJava 中是否有任何对象允许对一个 Observable 进行多个订阅?例如一个特定的主题?
例如对于下面给定的主题:
private PublishSubject<Location> locationSubject = PublishSubject.create();
我需要多个订阅:
locationSubject
.{several filtering, throttling functions here}
.subscribe(a -> doSomething(a));
locationSubject
.{several other filtering, throttling functions here}
.subscribe(a -> doSomethingElse(a));
因此在上述情况下,第二个订阅将覆盖第一个。谁可以让两个订阅保持有效?
为了完整起见:PublishSubject
可以将事件传输给多个订阅者。