RxJava2 - Mutlicasting Singles, Maybes, and Completables?

762 Views Asked by At

What is the recommend way to multicast Singles, Maybes, and Completables? Is it just recommended to turn them into standard Observables to multicast them?

    Observable<String> strings =
            Observable.just("Alpha", "Beta", "Gamma", "Delta", "Epsilon");

    Observable<Integer> lengths = strings.map(String::length);

    ConnectableObservable<List<Integer>> lengthsList = 
            lengths.toList().toObservable().publish();

I'm a bit surprised there is no ConnectableSingle, ConnectableMaybe, and ConnectableCompletable. What is the reasoning behind this? Is it just not worth the effort to develop?

1

There are 1 best solutions below

0
On

I think, .toObservable().publish() is the way to go.