Skip to content

Commit 5688cc8

Browse files
authored
2.x: switch to throwing Action, switchMapDelayError (#4357)
1 parent 059c7e6 commit 5688cc8

File tree

69 files changed

+996
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+996
-575
lines changed

src/main/java/io/reactivex/Completable.java

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -275,38 +275,38 @@ public static Completable error(final Throwable error) {
275275
return new CompletableError(error);
276276
}
277277

278+
278279
/**
279-
* Returns a Completable which when subscribed, executes the callable function, ignores its
280-
* normal result and emits onError or onCompleted only.
280+
* Returns a Completable instance that runs the given Action for each subscriber and
281+
* emits either an unchecked exception or simply completes.
281282
* <dl>
282283
* <dt><b>Scheduler:</b></dt>
283-
* <dd>{@code fromCallable} does not operate by default on a particular {@link Scheduler}.</dd>
284+
* <dd>{@code fromAction} does not operate by default on a particular {@link Scheduler}.</dd>
284285
* </dl>
285-
* @param callable the callable instance to execute for each subscriber
286+
* @param run the runnable to run for each subscriber
286287
* @return the new Completable instance
288+
* @throws NullPointerException if run is null
287289
*/
288290
@SchedulerSupport(SchedulerSupport.NONE)
289-
public static Completable fromCallable(final Callable<?> callable) {
290-
Objects.requireNonNull(callable, "callable is null");
291-
return new CompletableFromCallable(callable);
291+
public static Completable fromAction(final Action run) {
292+
Objects.requireNonNull(run, "run is null");
293+
return new CompletableFromAction(run);
292294
}
293-
295+
294296
/**
295-
* Returns a Completable instance that subscribes to the given publisher, ignores all values and
296-
* emits only the terminal event.
297+
* Returns a Completable which when subscribed, executes the callable function, ignores its
298+
* normal result and emits onError or onCompleted only.
297299
* <dl>
298300
* <dt><b>Scheduler:</b></dt>
299-
* <dd>{@code fromPublisher} does not operate by default on a particular {@link Scheduler}.</dd>
301+
* <dd>{@code fromCallable} does not operate by default on a particular {@link Scheduler}.</dd>
300302
* </dl>
301-
* @param <T> the type of the publisher
302-
* @param publisher the Publisher instance to subscribe to, not null
303+
* @param callable the callable instance to execute for each subscriber
303304
* @return the new Completable instance
304-
* @throws NullPointerException if publisher is null
305305
*/
306306
@SchedulerSupport(SchedulerSupport.NONE)
307-
public static <T> Completable fromPublisher(final Publisher<T> publisher) {
308-
Objects.requireNonNull(publisher, "publisher is null");
309-
return new CompletableFromPublisher<T>(publisher);
307+
public static Completable fromCallable(final Callable<?> callable) {
308+
Objects.requireNonNull(callable, "callable is null");
309+
return new CompletableFromCallable(callable);
310310
}
311311

312312
/**
@@ -349,25 +349,25 @@ public static <T> Completable fromObservable(final ObservableSource<T> observabl
349349
Objects.requireNonNull(observable, "observable is null");
350350
return new CompletableFromObservable<T>(observable);
351351
}
352-
353352

354353
/**
355-
* Returns a Completable instance that runs the given Runnable for each subscriber and
356-
* emits either an unchecked exception or simply completes.
354+
* Returns a Completable instance that subscribes to the given publisher, ignores all values and
355+
* emits only the terminal event.
357356
* <dl>
358357
* <dt><b>Scheduler:</b></dt>
359-
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
358+
* <dd>{@code fromPublisher} does not operate by default on a particular {@link Scheduler}.</dd>
360359
* </dl>
361-
* @param run the runnable to run for each subscriber
360+
* @param <T> the type of the publisher
361+
* @param publisher the Publisher instance to subscribe to, not null
362362
* @return the new Completable instance
363-
* @throws NullPointerException if run is null
363+
* @throws NullPointerException if publisher is null
364364
*/
365365
@SchedulerSupport(SchedulerSupport.NONE)
366-
public static Completable fromRunnable(final Runnable run) {
367-
Objects.requireNonNull(run, "run is null");
368-
return new CompletableFromRunnable(run);
366+
public static <T> Completable fromPublisher(final Publisher<T> publisher) {
367+
Objects.requireNonNull(publisher, "publisher is null");
368+
return new CompletableFromPublisher<T>(publisher);
369369
}
370-
370+
371371
/**
372372
* Returns a Completable instance that when subscribed to, subscribes to the Single instance and
373373
* emits a completion event if the single emits onSuccess or forwards any onError events.
@@ -944,10 +944,10 @@ public final Completable delay(final long delay, final TimeUnit unit, final Sche
944944
* @throws NullPointerException if onComplete is null
945945
*/
946946
@SchedulerSupport(SchedulerSupport.NONE)
947-
public final Completable doOnComplete(Runnable onComplete) {
947+
public final Completable doOnComplete(Action onComplete) {
948948
return doOnLifecycle(Functions.emptyConsumer(), Functions.emptyConsumer(),
949-
onComplete, Functions.EMPTY_RUNNABLE,
950-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE);
949+
onComplete, Functions.EMPTY_ACTION,
950+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION);
951951
}
952952

953953
/**
@@ -962,10 +962,10 @@ public final Completable doOnComplete(Runnable onComplete) {
962962
* @throws NullPointerException if onDispose is null
963963
*/
964964
@SchedulerSupport(SchedulerSupport.NONE)
965-
public final Completable doOnDispose(Runnable onDispose) {
965+
public final Completable doOnDispose(Action onDispose) {
966966
return doOnLifecycle(Functions.emptyConsumer(), Functions.emptyConsumer(),
967-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE,
968-
Functions.EMPTY_RUNNABLE, onDispose);
967+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION,
968+
Functions.EMPTY_ACTION, onDispose);
969969
}
970970

971971
/**
@@ -981,8 +981,8 @@ public final Completable doOnDispose(Runnable onDispose) {
981981
@SchedulerSupport(SchedulerSupport.NONE)
982982
public final Completable doOnError(Consumer<? super Throwable> onError) {
983983
return doOnLifecycle(Functions.emptyConsumer(), onError,
984-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE,
985-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE);
984+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION,
985+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION);
986986
}
987987

988988
/**
@@ -1003,10 +1003,10 @@ public final Completable doOnError(Consumer<? super Throwable> onError) {
10031003
private Completable doOnLifecycle(
10041004
final Consumer<? super Disposable> onSubscribe,
10051005
final Consumer<? super Throwable> onError,
1006-
final Runnable onComplete,
1007-
final Runnable onTerminate,
1008-
final Runnable onAfterTerminate,
1009-
final Runnable onDisposed) {
1006+
final Action onComplete,
1007+
final Action onTerminate,
1008+
final Action onAfterTerminate,
1009+
final Action onDisposed) {
10101010
Objects.requireNonNull(onSubscribe, "onSubscribe is null");
10111011
Objects.requireNonNull(onError, "onError is null");
10121012
Objects.requireNonNull(onComplete, "onComplete is null");
@@ -1030,8 +1030,8 @@ private Completable doOnLifecycle(
10301030
@SchedulerSupport(SchedulerSupport.NONE)
10311031
public final Completable doOnSubscribe(Consumer<? super Disposable> onSubscribe) {
10321032
return doOnLifecycle(onSubscribe, Functions.emptyConsumer(),
1033-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE,
1034-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE);
1033+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION,
1034+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION);
10351035
}
10361036

10371037
/**
@@ -1045,10 +1045,10 @@ public final Completable doOnSubscribe(Consumer<? super Disposable> onSubscribe)
10451045
* @return the new Completable instance
10461046
*/
10471047
@SchedulerSupport(SchedulerSupport.NONE)
1048-
public final Completable doOnTerminate(final Runnable onTerminate) {
1048+
public final Completable doOnTerminate(final Action onTerminate) {
10491049
return doOnLifecycle(Functions.emptyConsumer(), Functions.emptyConsumer(),
1050-
Functions.EMPTY_RUNNABLE, onTerminate,
1051-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE);
1050+
Functions.EMPTY_ACTION, onTerminate,
1051+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION);
10521052
}
10531053

10541054
/**
@@ -1062,10 +1062,10 @@ public final Completable doOnTerminate(final Runnable onTerminate) {
10621062
* @return the new Completable instance
10631063
*/
10641064
@SchedulerSupport(SchedulerSupport.NONE)
1065-
public final Completable doAfterTerminate(final Runnable onAfterTerminate) {
1065+
public final Completable doAfterTerminate(final Action onAfterTerminate) {
10661066
return doOnLifecycle(Functions.emptyConsumer(), Functions.emptyConsumer(),
1067-
onAfterTerminate, Functions.EMPTY_RUNNABLE,
1068-
Functions.EMPTY_RUNNABLE, Functions.EMPTY_RUNNABLE);
1067+
onAfterTerminate, Functions.EMPTY_ACTION,
1068+
Functions.EMPTY_ACTION, Functions.EMPTY_ACTION);
10691069
}
10701070

10711071
/**
@@ -1414,7 +1414,7 @@ public final void subscribe(CompletableObserver s) {
14141414
* @throws NullPointerException if either callback is null
14151415
*/
14161416
@SchedulerSupport(SchedulerSupport.NONE)
1417-
public final Disposable subscribe(final Runnable onComplete, final Consumer<? super Throwable> onError) {
1417+
public final Disposable subscribe(final Action onComplete, final Consumer<? super Throwable> onError) {
14181418
Objects.requireNonNull(onError, "onError is null");
14191419
Objects.requireNonNull(onComplete, "onComplete is null");
14201420

@@ -1443,7 +1443,7 @@ public final <T> void subscribe(final Observer<? super T> observer) {
14431443
}
14441444

14451445
/**
1446-
* Subscribes to this Completable and calls the given Runnable when this Completable
1446+
* Subscribes to this Completable and calls the given Action when this Completable
14471447
* completes normally.
14481448
* <p>
14491449
* If this Completable emits an error, it is sent to RxJavaPlugins.onError and gets swallowed.
@@ -1455,7 +1455,7 @@ public final <T> void subscribe(final Observer<? super T> observer) {
14551455
* @return the Disposable that allows cancelling the subscription
14561456
*/
14571457
@SchedulerSupport(SchedulerSupport.NONE)
1458-
public final Disposable subscribe(final Runnable onComplete) {
1458+
public final Disposable subscribe(final Action onComplete) {
14591459
Objects.requireNonNull(onComplete, "onComplete is null");
14601460

14611461
CallbackCompletableObserver s = new CallbackCompletableObserver(onComplete);

0 commit comments

Comments
 (0)