Skip to content

Commit

Permalink
Expand Observable#debounce and Flowable#debounce javadoc
Browse files Browse the repository at this point in the history
Mention that if the processing of a task takes too long
and a newer item arrives then the previous task will
get disposed interrupting a long running work.

Fixes: #6288
  • Loading branch information
RomanWuattier committed Jan 19, 2019
1 parent d40f923 commit fa8a161
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/io/reactivex/Flowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -8189,6 +8189,14 @@ public final Single<Long> count() {
* source Publisher that are followed by another item within a computed debounce duration.
* <p>
* <img width="640" height="425" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.f.png" alt="">
* <p>
* The delivery of the item happens on the thread of the first {@code onNext} or {@code onComplete}
* signal of the generated {@code Publisher}|{@code ObservableSource} sequence,
* which if takes too long, a newer item may arrive from the upstream, causing the
* generated sequence to get cancelled|disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>This operator does not support backpressure as it uses the {@code debounceSelector} to mark
Expand Down Expand Up @@ -8224,6 +8232,13 @@ public final <U> Flowable<T> debounce(Function<? super T, ? extends Publisher<U>
* will be emitted by the resulting Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
* <p>
* Delivery of the item after the grace period happens on the {@code computation} {@code Scheduler}'s
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
Expand Down Expand Up @@ -8259,6 +8274,13 @@ public final Flowable<T> debounce(long timeout, TimeUnit unit) {
* will be emitted by the resulting Publisher.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
* <p>
* Delivery of the item after the grace period happens on the given {@code Scheduler}'s
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/io/reactivex/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7297,6 +7297,14 @@ public final Single<Long> count() {
* source ObservableSource that are followed by another item within a computed debounce duration.
* <p>
* <img width="640" height="425" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.f.png" alt="">
* <p>
* The delivery of the item happens on the thread of the first {@code onNext} or {@code onComplete}
* signal of the generated {@code Publisher}|{@code ObservableSource} sequence,
* which if takes too long, a newer item may arrive from the upstream, causing the
* generated sequence to get cancelled|disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>This version of {@code debounce} does not operate by default on a particular {@link Scheduler}.</dd>
Expand Down Expand Up @@ -7326,6 +7334,13 @@ public final <U> Observable<T> debounce(Function<? super T, ? extends Observable
* will be emitted by the resulting ObservableSource.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
* <p>
* Delivery of the item after the grace period happens on the {@code computation} {@code Scheduler}'s
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
Expand Down Expand Up @@ -7357,6 +7372,13 @@ public final Observable<T> debounce(long timeout, TimeUnit unit) {
* will be emitted by the resulting ObservableSource.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
* <p>
* Delivery of the item after the grace period happens on the given {@code Scheduler}'s
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
* (yielding an {@code InterruptedException}). It is recommended processing items
* that may take long time to be moved to another thread via {@link #observeOn} applied after
* {@code debounce} itself.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>You specify which {@link Scheduler} this operator will use.</dd>
Expand Down

0 comments on commit fa8a161

Please sign in to comment.