|
19 | 19 | import org.reactivestreams.*;
|
20 | 20 |
|
21 | 21 | import io.reactivex.rxjava3.annotations.*;
|
| 22 | +import io.reactivex.rxjava3.core.Observable; |
22 | 23 | import io.reactivex.rxjava3.disposables.Disposable;
|
23 | 24 | import io.reactivex.rxjava3.exceptions.*;
|
24 | 25 | import io.reactivex.rxjava3.flowables.*;
|
|
28 | 29 | import io.reactivex.rxjava3.internal.jdk8.*;
|
29 | 30 | import io.reactivex.rxjava3.internal.operators.flowable.*;
|
30 | 31 | import io.reactivex.rxjava3.internal.operators.mixed.*;
|
31 |
| -import io.reactivex.rxjava3.internal.operators.observable.ObservableFromPublisher; |
| 32 | +import io.reactivex.rxjava3.internal.operators.observable.*; |
32 | 33 | import io.reactivex.rxjava3.internal.schedulers.ImmediateThinScheduler;
|
33 | 34 | import io.reactivex.rxjava3.internal.subscribers.*;
|
34 | 35 | import io.reactivex.rxjava3.internal.util.*;
|
@@ -12308,6 +12309,57 @@ public final Flowable<T> onBackpressureLatest() {
|
12308 | 12309 | return RxJavaPlugins.onAssembly(new FlowableOnBackpressureLatest<>(this));
|
12309 | 12310 | }
|
12310 | 12311 |
|
| 12312 | + /** |
| 12313 | + * Returns a {@code Flowable} instance that if the current {@code Flowable} emits an error, it will emit an {@code onComplete} |
| 12314 | + * and swallow the throwable. |
| 12315 | + * <p> |
| 12316 | + * <img width="640" height="372" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Flowable.onErrorComplete.png" alt=""> |
| 12317 | + * <dl> |
| 12318 | + * <dt><b>Backpressure:</b></dt> |
| 12319 | + * <dd>The operator doesn't interfere with backpressure which is determined by the current {@code Flowable}'s backpressure |
| 12320 | + * behavior.</dd> |
| 12321 | + * <dt><b>Scheduler:</b></dt> |
| 12322 | + * <dd>{@code onErrorComplete} does not operate by default on a particular {@link Scheduler}.</dd> |
| 12323 | + * </dl> |
| 12324 | + * @return the new {@code Flowable} instance |
| 12325 | + * @since 3.0.0 |
| 12326 | + */ |
| 12327 | + @CheckReturnValue |
| 12328 | + @SchedulerSupport(SchedulerSupport.NONE) |
| 12329 | + @BackpressureSupport(BackpressureKind.PASS_THROUGH) |
| 12330 | + @NonNull |
| 12331 | + public final Flowable<T> onErrorComplete() { |
| 12332 | + return onErrorComplete(Functions.alwaysTrue()); |
| 12333 | + } |
| 12334 | + |
| 12335 | + /** |
| 12336 | + * Returns a {@code Flowable} instance that if the current {@code Flowable} emits an error and the predicate returns |
| 12337 | + * {@code true}, it will emit an {@code onComplete} and swallow the throwable. |
| 12338 | + * <p> |
| 12339 | + * <img width="640" height="201" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Flowable.onErrorComplete.f.png" alt=""> |
| 12340 | + * <dl> |
| 12341 | + * <dt><b>Backpressure:</b></dt> |
| 12342 | + * <dd>The operator doesn't interfere with backpressure which is determined by the current {@code Flowable}'s backpressure |
| 12343 | + * behavior.</dd> |
| 12344 | + * <dt><b>Scheduler:</b></dt> |
| 12345 | + * <dd>{@code onErrorComplete} does not operate by default on a particular {@link Scheduler}.</dd> |
| 12346 | + * </dl> |
| 12347 | + * @param predicate the predicate to call when an {@link Throwable} is emitted which should return {@code true} |
| 12348 | + * if the {@code Throwable} should be swallowed and replaced with an {@code onComplete}. |
| 12349 | + * @return the new {@code Flowable} instance |
| 12350 | + * @throws NullPointerException if {@code predicate} is {@code null} |
| 12351 | + * @since 3.0.0 |
| 12352 | + */ |
| 12353 | + @CheckReturnValue |
| 12354 | + @BackpressureSupport(BackpressureKind.PASS_THROUGH) |
| 12355 | + @SchedulerSupport(SchedulerSupport.NONE) |
| 12356 | + @NonNull |
| 12357 | + public final Flowable<T> onErrorComplete(@NonNull Predicate<? super Throwable> predicate) { |
| 12358 | + Objects.requireNonNull(predicate, "predicate is null"); |
| 12359 | + |
| 12360 | + return RxJavaPlugins.onAssembly(new FlowableOnErrorComplete<>(this, predicate)); |
| 12361 | + } |
| 12362 | + |
12311 | 12363 | /**
|
12312 | 12364 | * Resumes the flow with a {@link Publisher} returned for the failure {@link Throwable} of the current {@code Flowable} by a
|
12313 | 12365 | * function instead of signaling the error via {@code onError}.
|
|
0 commit comments