Hi, I think Single should implement also org.reactivestreams.Publisher like Flowable.
Right now in io.reactivex.rxjava2 2.0.0 Single doesn't implement Publisher and this leads to being unable to do the following:
Flowable<String> colors = Flowable.fromArray("red", "green", "blue",
"red", "yellow", "green", "green");
Flowable<GroupedFlowable<String, String>> groupedColorsStream = colors
.groupBy(val -> val);
Flowable<Pair<String, Long>>
countedColors = groupedColorsStream
.flatMap(groupedFlow -> groupedFlow
.count()
.map(countVal -> new Pair<>(groupedFlow.getKey(), countVal))
);
countedColors.subscribe(System.out::println);
since count() returns Single
public final <R> Flowable<R> flatMap(Function<? super T, ? extends Publisher<? extends R>> mapper) {
return this.flatMap(mapper, false, bufferSize(), bufferSize());
}
It's not possible because of the receiver types are incompatible. Use toFlowable or flatMapSingle instead.
Thanks for answering
Most helpful comment
It's not possible because of the receiver types are incompatible. Use
toFlowableorflatMapSingleinstead.