Skip to content

Commit 19a9d33

Browse files
committed
improve javadocs for onErrorFlatMap( ) with link to wiki docs & marble diagram
1 parent 8bb52a0 commit 19a9d33

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,7 +5277,8 @@ public final Observable<T> onErrorResumeNext(final Observable<? extends T> resum
52775277
* By default, when an Observable encounters an error that prevents it from emitting the expected item to
52785278
* its {@link Observer}, the Observable invokes its Observer's {@code onError} method, and then quits
52795279
* without invoking any more of its Observer's methods. The {@code onErrorReturn} method changes this
5280-
* behavior. If you pass a function ({@code resumeFunction}) to an Observable's {@code onErrorReturn} method, if the original Observable encounters an error, instead of invoking its Observer's
5280+
* behavior. If you pass a function ({@code resumeFunction}) to an Observable's {@code onErrorReturn}
5281+
* method, if the original Observable encounters an error, instead of invoking its Observer's
52815282
* {@code onError} method, it will instead emit the return value of {@code resumeFunction}.
52825283
* <p>
52835284
* You can use this to prevent errors from propagating or to supply fallback data should errors be
@@ -5294,26 +5295,38 @@ public final Observable<T> onErrorReturn(Func1<Throwable, ? extends T> resumeFun
52945295
}
52955296

52965297
/**
5297-
* Allows inserting onNext events into a stream when onError events are received
5298-
* and continuing the original sequence instead of terminating. Thus it allows a sequence
5299-
* with multiple onError events.
5298+
* Allows inserting onNext events into a stream when onError events are received and continuing the original
5299+
* sequence instead of terminating. Thus it allows a sequence with multiple onError events.
5300+
* <p>
5301+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/onErrorFlatMap.png">
5302+
*
5303+
* @param resumeFunction
5304+
* a function that accepts an {@link OnErrorThrowable} representing the Throwable issued by the
5305+
* source Observable, and returns an Observable that issues items that will be emitted in place
5306+
* of the error
5307+
* @return the original Observable, with appropriately modified behavior
5308+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Error-Handling-Operators#onerrorflatmap">RxJava Wiki: onErrorFlatMap()</a>
53005309
*/
53015310
public final Observable<T> onErrorFlatMap(final Func1<OnErrorThrowable, ? extends Observable<? extends T>> resumeFunction) {
53025311
return lift(new OperatorOnErrorFlatMap<T>(resumeFunction));
53035312
}
53045313

53055314
/**
5306-
* Instruct an Observable to pass control to another Observable rather than invoking {@link Observer#onError onError} if it encounters an {@link java.lang.Exception}.
5315+
* Instruct an Observable to pass control to another Observable rather than invoking
5316+
* {@link Observer#onError onError} if it encounters an {@link java.lang.Exception}.
53075317
* <p>
5308-
* This differs from {@link #onErrorResumeNext} in that this one does not handle {@link java.lang.Throwable} or {@link java.lang.Error} but lets those continue through.
5318+
* This differs from {@link #onErrorResumeNext} in that this one does not handle {@link java.lang.Throwable}
5319+
* or {@link java.lang.Error} but lets those continue through.
53095320
* <p>
53105321
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/onExceptionResumeNextViaObservable.png">
53115322
* <p>
53125323
* By default, when an Observable encounters an exception that prevents it from emitting the expected item
53135324
* to its {@link Observer}, the Observable invokes its Observer's {@code onError} method, and then quits
53145325
* without invoking any more of its Observer's methods. The {@code onExceptionResumeNext} method changes
5315-
* this behavior. If you pass another Observable ({@code resumeSequence}) to an Observable's {@code onExceptionResumeNext} method, if the original Observable encounters an exception, instead of
5316-
* invoking its Observer's {@code onError} method, it will instead relinquish control to {@code resumeSequence} which will invoke the Observer's {@link Observer#onNext onNext} method if it is
5326+
* this behavior. If you pass another Observable ({@code resumeSequence}) to an Observable's
5327+
* {@code onExceptionResumeNext} method, if the original Observable encounters an exception, instead of
5328+
* invoking its Observer's {@code onError} method, it will instead relinquish control to
5329+
* {@code resumeSequence} which will invoke the Observer's {@link Observer#onNext onNext} method if it is
53175330
* able to do so. In such a case, because no Observable necessarily invokes {@code onError}, the Observer
53185331
* may never know that an exception happened.
53195332
* <p>

0 commit comments

Comments
 (0)