一个可观察到的两名观察员

时间:2015-06-10 10:03:12

标签: rx-java

除了ConnectableObservable<>之外,RxJava中是否有任何对象可以在Observable上进行多次订阅?例如一个特定的主题?

E.g。对于以下给定主题:

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

因此,在上述情况下,第二个订阅将覆盖第一个订阅。谁可以保持两个订阅活着?

1 个答案:

答案 0 :(得分:0)

为了完整起见:PublishSubject可以将事件传输给多个订阅者。

相关问题