@@ -5999,7 +5999,9 @@ public final Observable<T> mergeWith(Observable<? extends T> t1) {
5999
5999
6000
6000
/**
6001
6001
* Modifies an Observable to perform its emissions and notifications on a specified {@link Scheduler},
6002
- * asynchronously with an unbounded buffer.
6002
+ * asynchronously with a bounded buffer.
6003
+ * <p>Note that onError notifications will cut ahead of onNext notifications on the emission thread if Scheduler is truly
6004
+ * asynchronous. If strict event ordering is required, consider using the {@link #observeOn(Scheduler, boolean)} overload.
6003
6005
* <p>
6004
6006
* <img width="640" height="308" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/observeOn.png" alt="">
6005
6007
* <dl>
@@ -6014,12 +6016,43 @@ public final Observable<T> mergeWith(Observable<? extends T> t1) {
6014
6016
* @see <a href="http://reactivex.io/documentation/operators/observeon.html">ReactiveX operators documentation: ObserveOn</a>
6015
6017
* @see <a href="http://www.grahamlea.com/2014/07/rxjava-threading-examples/">RxJava Threading Examples</a>
6016
6018
* @see #subscribeOn
6019
+ * @see #observeOn(Scheduler, boolean)
6017
6020
*/
6018
6021
public final Observable<T> observeOn(Scheduler scheduler) {
6019
6022
if (this instanceof ScalarSynchronousObservable) {
6020
6023
return ((ScalarSynchronousObservable<T>)this).scalarScheduleOn(scheduler);
6021
6024
}
6022
- return lift(new OperatorObserveOn<T>(scheduler));
6025
+ return lift(new OperatorObserveOn<T>(scheduler, false));
6026
+ }
6027
+
6028
+ /**
6029
+ * Modifies an Observable to perform its emissions and notifications on a specified {@link Scheduler},
6030
+ * asynchronously with a bounded buffer and optionally delays onError notifications.
6031
+ * <p>
6032
+ * <img width="640" height="308" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/observeOn.png" alt="">
6033
+ * <dl>
6034
+ * <dt><b>Scheduler:</b></dt>
6035
+ * <dd>you specify which {@link Scheduler} this operator will use</dd>
6036
+ * </dl>
6037
+ *
6038
+ * @param scheduler
6039
+ * the {@link Scheduler} to notify {@link Observer}s on
6040
+ * @param delayError
6041
+ * indicates if the onError notification may not cut ahead of onNext notification on the other side of the
6042
+ * scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received
6043
+ * from upstream
6044
+ * @return the source Observable modified so that its {@link Observer}s are notified on the specified
6045
+ * {@link Scheduler}
6046
+ * @see <a href="http://reactivex.io/documentation/operators/observeon.html">ReactiveX operators documentation: ObserveOn</a>
6047
+ * @see <a href="http://www.grahamlea.com/2014/07/rxjava-threading-examples/">RxJava Threading Examples</a>
6048
+ * @see #subscribeOn
6049
+ * @see #observeOn(Scheduler)
6050
+ */
6051
+ public final Observable<T> observeOn(Scheduler scheduler, boolean delayError) {
6052
+ if (this instanceof ScalarSynchronousObservable) {
6053
+ return ((ScalarSynchronousObservable<T>)this).scalarScheduleOn(scheduler);
6054
+ }
6055
+ return lift(new OperatorObserveOn<T>(scheduler, delayError));
6023
6056
}
6024
6057
6025
6058
/**
0 commit comments