flatMap

fun <T, R> Observable<T>.flatMap(maxConcurrency: Int = Int.MAX_VALUE, mapper: (T) -> Observable<R>): Observable<R>

Calls the mapper for each element emitted by the Observable and subscribes to the returned inner Observable. Emits elements from inner Observables. The maximum number of concurrently subscribed inner Observables is determined by the maxConcurrency argument.

By default, all inner Observables are subscribed concurrently without any limits.

Please refer to the corresponding RxJava document.


fun <T, U, R> Observable<T>.flatMap(resultSelector: (T, U) -> R, maxConcurrency: Int = Int.MAX_VALUE, mapper: (T) -> Observable<U>): Observable<R>

Calls the mapper for each element emitted by the Observable and subscribes to the returned inner Observable. For each element U emitted by an inner Observable, calls resultSelector with the original source element T and the inner element U, and emits the result element R. The maximum number of concurrently subscribed inner Observables is determined by the maxConcurrency argument.

By default, all inner Observables are subscribed concurrently without any limits.

Please refer to the corresponding RxJava document.