Skip to content

Commit 0f21ba8

Browse files
authored
3.x: fromRunnable/fromAction javadoc improvements (#7071)
1 parent 7693126 commit 0f21ba8

File tree

4 files changed

+54
-23
lines changed

4 files changed

+54
-23
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ public static Completable error(@NonNull Throwable throwable) {
528528
}
529529

530530
/**
531-
* Returns a {@code Completable} instance that runs the given {@link Action} for each subscriber and
532-
* emits either an unchecked exception or simply completes.
531+
* Returns a {@code Completable} instance that runs the given {@link Action} for each {@link CompletableObserver} and
532+
* emits either an exception or simply completes.
533533
* <p>
534534
* <img width="640" height="297" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Completable.fromAction.png" alt="">
535535
* <dl>
@@ -543,7 +543,7 @@ public static Completable error(@NonNull Throwable throwable) {
543543
* {@link RxJavaPlugins#onError(Throwable)} as an {@link io.reactivex.rxjava3.exceptions.UndeliverableException UndeliverableException}.
544544
* </dd>
545545
* </dl>
546-
* @param action the {@code Action} to run for each subscribing {@link CompletableObserver}
546+
* @param action the {@code Action} to run for each subscribing {@code CompletableObserver}
547547
* @return the new {@code Completable} instance
548548
* @throws NullPointerException if {@code action} is {@code null}
549549
*/
@@ -636,14 +636,19 @@ public static <T> Completable fromMaybe(@NonNull MaybeSource<T> maybe) {
636636

637637
/**
638638
* Returns a {@code Completable} instance that runs the given {@link Runnable} for each {@link CompletableObserver} and
639-
* emits either its exception or simply completes.
639+
* emits either its unchecked exception or simply completes.
640640
* <p>
641641
* <img width="640" height="297" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Completable.fromRunnable.png" alt="">
642+
* <p>
643+
* If the code to be wrapped needs to throw a checked or more broader {@link Throwable} exception, that
644+
* exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively,
645+
* use the {@link #fromAction(Action)} method which allows the wrapped code to throw any {@code Throwable}
646+
* exception and will signal it to observers as-is.
642647
* <dl>
643648
* <dt><b>Scheduler:</b></dt>
644649
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
645650
* <dt><b>Error handling:</b></dt>
646-
* <dd> If the {@code Runnable} throws an exception, the respective {@link Throwable} is
651+
* <dd> If the {@code Runnable} throws an exception, the respective {@code Throwable} is
647652
* delivered to the downstream via {@link CompletableObserver#onError(Throwable)},
648653
* except when the downstream has disposed this {@code Completable} source.
649654
* In this latter case, the {@code Throwable} is delivered to the global error handler via
@@ -653,6 +658,7 @@ public static <T> Completable fromMaybe(@NonNull MaybeSource<T> maybe) {
653658
* @param run the {@code Runnable} to run for each {@code CompletableObserver}
654659
* @return the new {@code Completable} instance
655660
* @throws NullPointerException if {@code run} is {@code null}
661+
* @see #fromAction(Action)
656662
*/
657663
@CheckReturnValue
658664
@NonNull

src/main/java/io/reactivex/rxjava3/core/Flowable.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ public static <T> Flowable<T> error(@NonNull Throwable throwable) {
21132113
}
21142114

21152115
/**
2116-
* Returns a {@code Flowable} instance that runs the given {@link Action} for each subscriber and
2116+
* Returns a {@code Flowable} instance that runs the given {@link Action} for each {@link Subscriber} and
21172117
* emits either its exception or simply completes.
21182118
* <p>
21192119
* <img width="640" height="285" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Flowable.fromAction.png" alt="">
@@ -2131,7 +2131,7 @@ public static <T> Flowable<T> error(@NonNull Throwable throwable) {
21312131
* </dd>
21322132
* </dl>
21332133
* @param <T> the target type
2134-
* @param action the {@code Action} to run for each subscriber
2134+
* @param action the {@code Action} to run for each {@code Subscriber}
21352135
* @return the new {@code Flowable} instance
21362136
* @throws NullPointerException if {@code action} is {@code null}
21372137
* @since 3.0.0
@@ -2497,28 +2497,34 @@ public static <T> Flowable<T> fromPublisher(@NonNull Publisher<@NonNull ? extend
24972497
}
24982498

24992499
/**
2500-
* Returns a {@code Flowable} instance that runs the given {@link Runnable} for each subscriber and
2501-
* emits either its exception or simply completes.
2500+
* Returns a {@code Flowable} instance that runs the given {@link Runnable} for each {@link Subscriber} and
2501+
* emits either its unchecked exception or simply completes.
25022502
* <p>
25032503
* <img width="640" height="286" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Flowable.fromRunnable.png" alt="">
2504+
* <p>
2505+
* If the code to be wrapped needs to throw a checked or more broader {@link Throwable} exception, that
2506+
* exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively,
2507+
* use the {@link #fromAction(Action)} method which allows the wrapped code to throw any {@code Throwable}
2508+
* exception and will signal it to observers as-is.
25042509
* <dl>
25052510
* <dt><b>Backpressure:</b></dt>
25062511
* <dd>This source doesn't produce any elements and effectively ignores downstream backpressure.</dd>
25072512
* <dt><b>Scheduler:</b></dt>
25082513
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
25092514
* <dt><b>Error handling:</b></dt>
2510-
* <dd> If the {@code Runnable} throws an exception, the respective {@link Throwable} is
2515+
* <dd> If the {@code Runnable} throws an exception, the respective {@code Throwable} is
25112516
* delivered to the downstream via {@link Subscriber#onError(Throwable)},
25122517
* except when the downstream has canceled the resulting {@code Flowable} source.
25132518
* In this latter case, the {@code Throwable} is delivered to the global error handler via
25142519
* {@link RxJavaPlugins#onError(Throwable)} as an {@link io.reactivex.rxjava3.exceptions.UndeliverableException UndeliverableException}.
25152520
* </dd>
25162521
* </dl>
25172522
* @param <T> the target type
2518-
* @param run the {@code Runnable} to run for each subscriber
2523+
* @param run the {@code Runnable} to run for each {@code Subscriber}
25192524
* @return the new {@code Flowable} instance
25202525
* @throws NullPointerException if {@code run} is {@code null}
25212526
* @since 3.0.0
2527+
* @see #fromAction(Action)
25222528
*/
25232529
@CheckReturnValue
25242530
@NonNull

src/main/java/io/reactivex/rxjava3/core/Maybe.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ public static <T> Maybe<T> error(@NonNull Supplier<? extends Throwable> supplier
967967
}
968968

969969
/**
970-
* Returns a {@code Maybe} instance that runs the given {@link Action} for each observer and
970+
* Returns a {@code Maybe} instance that runs the given {@link Action} for each {@link MaybeObserver} and
971971
* emits either its exception or simply completes.
972972
* <p>
973973
* <img width="640" height="287" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.fromAction.png" alt="">
@@ -983,7 +983,7 @@ public static <T> Maybe<T> error(@NonNull Supplier<? extends Throwable> supplier
983983
* </dd>
984984
* </dl>
985985
* @param <T> the target type
986-
* @param action the {@code Action} to run for each observer
986+
* @param action the {@code Action} to run for each {@code MaybeObserver}
987987
* @return the new {@code Maybe} instance
988988
* @throws NullPointerException if {@code action} is {@code null}
989989
*/
@@ -1208,18 +1208,31 @@ public static <T> Maybe<T> fromPublisher(@NonNull Publisher<T> source) {
12081208
}
12091209

12101210
/**
1211-
* Returns a {@code Maybe} instance that runs the given {@link Runnable} for each observer and
1212-
* emits either its exception or simply completes.
1211+
* Returns a {@code Maybe} instance that runs the given {@link Runnable} for each {@link MaybeObserver} and
1212+
* emits either its unchecked exception or simply completes.
12131213
* <p>
12141214
* <img width="640" height="287" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.fromRunnable.png" alt="">
1215+
* <p>
1216+
* If the code to be wrapped needs to throw a checked or more broader {@link Throwable} exception, that
1217+
* exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively,
1218+
* use the {@link #fromAction(Action)} method which allows the wrapped code to throw any {@code Throwable}
1219+
* exception and will signal it to observers as-is.
12151220
* <dl>
12161221
* <dt><b>Scheduler:</b></dt>
12171222
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
1223+
* <dt><b>Error handling:</b></dt>
1224+
* <dd> If the {@code Runnable} throws an exception, the respective {@code Throwable} is
1225+
* delivered to the downstream via {@link MaybeObserver#onError(Throwable)},
1226+
* except when the downstream has disposed this {@code Maybe} source.
1227+
* In this latter case, the {@code Throwable} is delivered to the global error handler via
1228+
* {@link RxJavaPlugins#onError(Throwable)} as an {@link io.reactivex.rxjava3.exceptions.UndeliverableException UndeliverableException}.
1229+
* </dd>
12181230
* </dl>
12191231
* @param <T> the target type
1220-
* @param run the {@code Runnable} to run for each observer
1232+
* @param run the {@code Runnable} to run for each {@code MaybeObserver}
12211233
* @return the new {@code Maybe} instance
12221234
* @throws NullPointerException if {@code run} is {@code null}
1235+
* @see #fromAction(Action)
12231236
*/
12241237
@CheckReturnValue
12251238
@NonNull

src/main/java/io/reactivex/rxjava3/core/Observable.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,10 +1855,10 @@ public static <T> Observable<T> error(@NonNull Throwable throwable) {
18551855
}
18561856

18571857
/**
1858-
* Returns an {@code Observable} instance that runs the given {@link Action} for each subscriber and
1858+
* Returns an {@code Observable} instance that runs the given {@link Action} for each {@link Observer} and
18591859
* emits either its exception or simply completes.
18601860
* <p>
1861-
* <img width="640" height="287" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.fromAction.png" alt="">
1861+
* <img width="640" height="287" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Observable.fromAction.png" alt="">
18621862
* <dl>
18631863
* <dt><b>Scheduler:</b></dt>
18641864
* <dd>{@code fromAction} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -1871,7 +1871,7 @@ public static <T> Observable<T> error(@NonNull Throwable throwable) {
18711871
* </dd>
18721872
* </dl>
18731873
* @param <T> the target type
1874-
* @param action the {@code Action} to run for each subscriber
1874+
* @param action the {@code Action} to run for each {@code Observer}
18751875
* @return the new {@code Observable} instance
18761876
* @throws NullPointerException if {@code action} is {@code null}
18771877
* @since 3.0.0
@@ -2145,26 +2145,32 @@ public static <T> Observable<T> fromPublisher(@NonNull Publisher<@NonNull ? exte
21452145
}
21462146

21472147
/**
2148-
* Returns an {@code Observable} instance that runs the given {@link Runnable} for each observer and
2149-
* emits either its exception or simply completes.
2148+
* Returns an {@code Observable} instance that runs the given {@link Runnable} for each {@link Observer} and
2149+
* emits either its unchecked exception or simply completes.
21502150
* <p>
21512151
* <img width="640" height="286" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Observable.fromRunnable.png" alt="">
2152+
* <p>
2153+
* If the code to be wrapped needs to throw a checked or more broader {@link Throwable} exception, that
2154+
* exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively,
2155+
* use the {@link #fromAction(Action)} method which allows the wrapped code to throw any {@code Throwable}
2156+
* exception and will signal it to observers as-is.
21522157
* <dl>
21532158
* <dt><b>Scheduler:</b></dt>
21542159
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
21552160
* <dt><b>Error handling:</b></dt>
2156-
* <dd> If the {@code Runnable} throws an exception, the respective {@link Throwable} is
2161+
* <dd> If the {@code Runnable} throws an exception, the respective {@code Throwable} is
21572162
* delivered to the downstream via {@link Observer#onError(Throwable)},
21582163
* except when the downstream has canceled the resulting {@code Observable} source.
21592164
* In this latter case, the {@code Throwable} is delivered to the global error handler via
21602165
* {@link RxJavaPlugins#onError(Throwable)} as an {@link io.reactivex.rxjava3.exceptions.UndeliverableException UndeliverableException}.
21612166
* </dd>
21622167
* </dl>
21632168
* @param <T> the target type
2164-
* @param run the {@code Runnable} to run for each observer
2169+
* @param run the {@code Runnable} to run for each {@code Observer}
21652170
* @return the new {@code Observable} instance
21662171
* @throws NullPointerException if {@code run} is {@code null}
21672172
* @since 3.0.0
2173+
* @see #fromAction(Action)
21682174
*/
21692175
@CheckReturnValue
21702176
@NonNull

0 commit comments

Comments
 (0)