| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.internal.operators.mixed; |
| 15 |
|
| 16 |
import org.reactivestreams.*; |
| 17 |
|
| 18 |
import io.reactivex.rxjava3.core.*; |
| 19 |
import io.reactivex.rxjava3.functions.Function; |
| 20 |
import io.reactivex.rxjava3.internal.operators.mixed.FlowableConcatMapMaybe.ConcatMapMaybeSubscriber; |
| 21 |
import io.reactivex.rxjava3.internal.util.ErrorMode; |
| 22 |
|
| 23 |
/** |
| 24 |
* Maps each upstream item into a {@link MaybeSource}, subscribes to them one after the other terminates |
| 25 |
* and relays their success values, optionally delaying any errors till the main and inner sources |
| 26 |
* terminate. |
| 27 |
* <p>History: 2.1.11 - experimental |
| 28 |
* @param <T> the upstream element type |
| 29 |
* @param <R> the output element type |
| 30 |
* @since 2.2 |
| 31 |
*/ |
| 32 |
public final class FlowableConcatMapMaybePublisher<T, R> extends Flowable<R> { |
| 33 |
|
| 34 |
final Publisher<T> source; |
| 35 |
|
| 36 |
final Function<? super T, ? extends MaybeSource<? extends R>> mapper; |
| 37 |
|
| 38 |
final ErrorMode errorMode; |
| 39 |
|
| 40 |
final int prefetch; |
| 41 |
|
| 42 |
public FlowableConcatMapMaybePublisher(Publisher<T> source, |
| 43 |
Function<? super T, ? extends MaybeSource<? extends R>> mapper, |
| 44 |
ErrorMode errorMode, int prefetch) { |
| 45 |
this.source = source; |
| 46 |
this.mapper = mapper; |
| 47 |
this.errorMode = errorMode; |
| 48 |
this.prefetch = prefetch; |
| 49 |
} |
| 50 |
|
| 51 |
@Override |
| 52 |
protected void subscribeActual(Subscriber<? super R> s) { |
| 53 |
source.subscribe(new ConcatMapMaybeSubscriber<>(s, mapper, prefetch, errorMode)); |
| 54 |
} |
| 55 |
} |