I'm not sure I understood your question correctly, but I believe that you are looking for a way to share the outliers observed between several subscribers. There are several ways to do this. For example, you can use Connectable Observable as follows:
ConnectableObservable<Integer> obs = Observable.range(1,3).publish(); obs.subscribe(item -> System.out.println("Sub A: " + item)); obs.subscribe(item -> System.out.println("Sub B: " + item)); obs.connect();
Output:
Sub A: 1 Sub B: 1 Sub A: 2 Sub B: 2 Sub A: 3 Sub B: 3
Alternatively, you can use PublishSubject :
PublishSubject<Integer> subject = PublishSubject.create();
Output:
Sub A: 1 Sub B: 1 Sub A: 2 Sub B: 2 Sub A: 3 Sub B: 3
Both of these examples are single-threaded, but you can easily add observOn or subscirbeOn calls to make them asynchronous.
Malt
source share