Flowable.parallel vs Flowable.flatMap?

RxJava 2.0.5 introduces a type ParallelFlowablecorresponding to the operator Flowable.parallel(). I found that the general advice on achieving parallelism is flatMapas follows:

Flowable.just(1,2,3)
    .flatMap(x -> Flowable.just(x)
        .observeOn(Schedulers.computation())
        .map(y -> y + 1))
    .forEach(System.out::println);

When is it appropriate to use flatMapfor parallelism, and when is it better to use ParallelFlowable?

+6
source share
1 answer

I found that the general advice for achieving parallelism is with flatMap as follows:

Those tips start before the introduction parallel, so you should consider the evolution of the API since then.

When is it advisable to use flatMap for parallelism, and when is it better to use ParallelFlowable?

ParallelFlowable : map, filter, doOnNext, reduce, flatMap .. API Flowable. , - "", , , Flowable.flatMap parallelism ( groupBy parallelism).

(code).

+6

All Articles