Skip to content

Commit 95dde6f

Browse files
authored
2.x: clarify dematerialize() and terminal items/signals (#5897)
1 parent e3f38ec commit 95dde6f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

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

+19
Original file line numberDiff line numberDiff line change
@@ -8276,6 +8276,25 @@ public final Flowable<T> delaySubscription(long delay, TimeUnit unit, Scheduler
82768276
* represent.
82778277
* <p>
82788278
* <img width="640" height="335" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/dematerialize.png" alt="">
8279+
* <p>
8280+
* When the upstream signals an {@link Notification#createOnError(Throwable) onError} or
8281+
* {@link Notification#createOnComplete() onComplete} item, the
8282+
* returned Flowable cancels the flow and terminates with that type of terminal event:
8283+
* <pre><code>
8284+
* Flowable.just(createOnNext(1), createOnComplete(), createOnNext(2))
8285+
* .doOnCancel(() -&gt; System.out.println("Cancelled!"));
8286+
* .test()
8287+
* .assertResult(1);
8288+
* </code></pre>
8289+
* If the upstream signals {@code onError} or {@code onComplete} directly, the flow is terminated
8290+
* with the same event.
8291+
* <pre><code>
8292+
* Flowable.just(createOnNext(1), createOnNext(2))
8293+
* .test()
8294+
* .assertResult(1, 2);
8295+
* </code></pre>
8296+
* If this behavior is not desired, the completion can be suppressed by applying {@link #concatWith(Publisher)}
8297+
* with a {@link #never()} source.
82798298
* <dl>
82808299
* <dt><b>Backpressure:</b></dt>
82818300
* <dd>The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s

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

+19
Original file line numberDiff line numberDiff line change
@@ -7490,6 +7490,25 @@ public final Observable<T> delaySubscription(long delay, TimeUnit unit, Schedule
74907490
* represent.
74917491
* <p>
74927492
* <img width="640" height="335" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/dematerialize.png" alt="">
7493+
* <p>
7494+
* When the upstream signals an {@link Notification#createOnError(Throwable) onError} or
7495+
* {@link Notification#createOnComplete() onComplete} item, the
7496+
* returned Observable cancels the flow and terminates with that type of terminal event:
7497+
* <pre><code>
7498+
* Observable.just(createOnNext(1), createOnComplete(), createOnNext(2))
7499+
* .doOnCancel(() -&gt; System.out.println("Cancelled!"));
7500+
* .test()
7501+
* .assertResult(1);
7502+
* </code></pre>
7503+
* If the upstream signals {@code onError} or {@code onComplete} directly, the flow is terminated
7504+
* with the same event.
7505+
* <pre><code>
7506+
* Observable.just(createOnNext(1), createOnNext(2))
7507+
* .test()
7508+
* .assertResult(1, 2);
7509+
* </code></pre>
7510+
* If this behavior is not desired, the completion can be suppressed by applying {@link #concatWith(ObservableSource)}
7511+
* with a {@link #never()} source.
74937512
* <dl>
74947513
* <dt><b>Scheduler:</b></dt>
74957514
* <dd>{@code dematerialize} does not operate by default on a particular {@link Scheduler}.</dd>

0 commit comments

Comments
 (0)