diff --git a/src/main/java/io/reactivex/Maybe.java b/src/main/java/io/reactivex/Maybe.java index 5657315bc1..3afe266025 100644 --- a/src/main/java/io/reactivex/Maybe.java +++ b/src/main/java/io/reactivex/Maybe.java @@ -3084,7 +3084,7 @@ public final Maybe hide() { /** * Ignores the item emitted by the source Maybe and only calls {@code onComplete} or {@code onError}. *

- * + * *

*
Scheduler:
*
{@code ignoreElement} does not operate by default on a particular {@link Scheduler}.
diff --git a/src/main/java/io/reactivex/Single.java b/src/main/java/io/reactivex/Single.java index d3b67f211b..c270100f09 100644 --- a/src/main/java/io/reactivex/Single.java +++ b/src/main/java/io/reactivex/Single.java @@ -3491,9 +3491,7 @@ public final R to(Function, R> convert) { * and calls {@code onComplete} when this source {@link Single} calls * {@code onSuccess}. Error terminal event is propagated. *

- * + * *

*
Scheduler:
*
{@code toCompletable} does not operate by default on a particular {@link Scheduler}.
@@ -3503,13 +3501,36 @@ public final R to(Function, R> convert) { * calls {@code onSuccess}. * @see ReactiveX documentation: Completable * @since 2.0 + * @deprecated see {@link #ignoreElement()} instead, will be removed in 3.0 */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @Deprecated public final Completable toCompletable() { return RxJavaPlugins.onAssembly(new CompletableFromSingle(this)); } + /** + * Returns a {@link Completable} that ignores the success value of this {@link Single} + * and calls {@code onComplete} instead on the returned {@code Completable}. + *

+ * + *

+ *
Scheduler:
+ *
{@code ignoreElement} does not operate by default on a particular {@link Scheduler}.
+ *
+ * + * @return a {@link Completable} that calls {@code onComplete} on it's observer when the source {@link Single} + * calls {@code onSuccess}. + * @see ReactiveX documentation: Completable + * @since 2.1.13 + */ + @CheckReturnValue + @SchedulerSupport(SchedulerSupport.NONE) + public final Completable ignoreElement() { + return RxJavaPlugins.onAssembly(new CompletableFromSingle(this)); + } + /** * Converts this Single into a {@link Flowable}. *

diff --git a/src/test/java/io/reactivex/internal/operators/single/SingleMiscTest.java b/src/test/java/io/reactivex/internal/operators/single/SingleMiscTest.java index 96f92a3d9e..160579aab1 100644 --- a/src/test/java/io/reactivex/internal/operators/single/SingleMiscTest.java +++ b/src/test/java/io/reactivex/internal/operators/single/SingleMiscTest.java @@ -254,6 +254,7 @@ public void timeoutOther() throws Exception { } @Test + @SuppressWarnings("deprecation") public void toCompletable() { Single.just(1) .toCompletable() @@ -266,6 +267,19 @@ public void toCompletable() { .assertFailure(TestException.class); } + @Test + public void ignoreElement() { + Single.just(1) + .ignoreElement() + .test() + .assertResult(); + + Single.error(new TestException()) + .ignoreElement() + .test() + .assertFailure(TestException.class); + } + @Test public void toObservable() { Single.just(1)