본문
180315(목) - RxJava2 (concatMap)
RxJava2
concatMap
transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable

The FlatMap operator transforms an Observable by applying a function that you specify to each item emitted by the source Observable, where that function returns an Observable that itself emits items. FlatMap then merges the emissions of these resulting Observables, emitting these merged results as its own sequence.
This method is useful, for example, when you have an Observable that emits a series of items that themselves have Observable members or are in other ways transformable into Observables, so that you can create a new Observable that emits the complete collection of items emitted by the sub-Observables of these items.
Note that FlatMap merges the emissions of these Observables, so that they may interleave.
In several of the language-specific implementations there is also an operator that does not interleave the emissions from the transformed Observables, but instead emits these emissions in strict order, often called ConcatMap or something similar.
concatMap
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final <R> Flowable<R> concatMap(Function<? super T,? extends Publisher<? extends R>> mapper)
- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the sourcePublisher
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the inner Publisher sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the source Publisher, returns an Publisher- Returns:
- a Flowable that emits the result of applying the transformation function to each item emitted by the source Publisher and concatenating the Publishers obtained from this transformation
- See Also:
- ReactiveX operators documentation: FlatMap
concatMap
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final <R> Flowable<R> concatMap(Function<? super T,? extends Publisher<? extends R>> mapper, int prefetch)
- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the sourcePublisher
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the inner Publisher sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the source Publisher, returns an Publisherprefetch
- the number of elements to prefetch from the current Flowable- Returns:
- a Flowable that emits the result of applying the transformation function to each item emitted by the source Publisher and concatenating the Publishers obtained from this transformation
- See Also:
- ReactiveX operators documentation: FlatMap
'Mobile > RxJava2' 카테고리의 다른 글
180107(수) - RxJava2 (buffer) (0) | 2018.02.07 |
---|---|
180206(화) - RxJava2 (timer) (0) | 2018.02.06 |
180205(월) - RxJava2 (start) (0) | 2018.02.05 |
180104(목) - RxJava2 (repeat) (0) | 2018.01.04 |
180103(수) - RxJava2 (range) (0) | 2018.01.03 |
댓글