Skip to content

Commit 3fbfcc9

Browse files
RomanWuattierakarnokd
authored andcommitted
Expand Observable#debounce and Flowable#debounce javadoc (ReactiveX#6377)
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: ReactiveX#6288
1 parent 1484106 commit 3fbfcc9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8189,6 +8189,14 @@ public final Single<Long> count() {
81898189
* source Publisher that are followed by another item within a computed debounce duration.
81908190
* <p>
81918191
* <img width="640" height="425" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.f.png" alt="">
8192+
* <p>
8193+
* The delivery of the item happens on the thread of the first {@code onNext} or {@code onComplete}
8194+
* signal of the generated {@code Publisher} sequence,
8195+
* which if takes too long, a newer item may arrive from the upstream, causing the
8196+
* generated sequence to get cancelled, which may also interrupt any downstream blocking operation
8197+
* (yielding an {@code InterruptedException}). It is recommended processing items
8198+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
8199+
* {@code debounce} itself.
81928200
* <dl>
81938201
* <dt><b>Backpressure:</b></dt>
81948202
* <dd>This operator does not support backpressure as it uses the {@code debounceSelector} to mark
@@ -8224,6 +8232,13 @@ public final <U> Flowable<T> debounce(Function<? super T, ? extends Publisher<U>
82248232
* will be emitted by the resulting Publisher.
82258233
* <p>
82268234
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
8235+
* <p>
8236+
* Delivery of the item after the grace period happens on the {@code computation} {@code Scheduler}'s
8237+
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
8238+
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
8239+
* (yielding an {@code InterruptedException}). It is recommended processing items
8240+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
8241+
* {@code debounce} itself.
82278242
* <dl>
82288243
* <dt><b>Backpressure:</b></dt>
82298244
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
@@ -8259,6 +8274,13 @@ public final Flowable<T> debounce(long timeout, TimeUnit unit) {
82598274
* will be emitted by the resulting Publisher.
82608275
* <p>
82618276
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
8277+
* <p>
8278+
* Delivery of the item after the grace period happens on the given {@code Scheduler}'s
8279+
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
8280+
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
8281+
* (yielding an {@code InterruptedException}). It is recommended processing items
8282+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
8283+
* {@code debounce} itself.
82628284
* <dl>
82638285
* <dt><b>Backpressure:</b></dt>
82648286
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7297,6 +7297,14 @@ public final Single<Long> count() {
72977297
* source ObservableSource that are followed by another item within a computed debounce duration.
72987298
* <p>
72997299
* <img width="640" height="425" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.f.png" alt="">
7300+
* <p>
7301+
* The delivery of the item happens on the thread of the first {@code onNext} or {@code onComplete}
7302+
* signal of the generated {@code ObservableSource} sequence,
7303+
* which if takes too long, a newer item may arrive from the upstream, causing the
7304+
* generated sequence to get disposed, which may also interrupt any downstream blocking operation
7305+
* (yielding an {@code InterruptedException}). It is recommended processing items
7306+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
7307+
* {@code debounce} itself.
73007308
* <dl>
73017309
* <dt><b>Scheduler:</b></dt>
73027310
* <dd>This version of {@code debounce} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -7326,6 +7334,13 @@ public final <U> Observable<T> debounce(Function<? super T, ? extends Observable
73267334
* will be emitted by the resulting ObservableSource.
73277335
* <p>
73287336
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
7337+
* <p>
7338+
* Delivery of the item after the grace period happens on the {@code computation} {@code Scheduler}'s
7339+
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
7340+
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
7341+
* (yielding an {@code InterruptedException}). It is recommended processing items
7342+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
7343+
* {@code debounce} itself.
73297344
* <dl>
73307345
* <dt><b>Scheduler:</b></dt>
73317346
* <dd>{@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
@@ -7357,6 +7372,13 @@ public final Observable<T> debounce(long timeout, TimeUnit unit) {
73577372
* will be emitted by the resulting ObservableSource.
73587373
* <p>
73597374
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
7375+
* <p>
7376+
* Delivery of the item after the grace period happens on the given {@code Scheduler}'s
7377+
* {@code Worker} which if takes too long, a newer item may arrive from the upstream, causing the
7378+
* {@code Worker}'s task to get disposed, which may also interrupt any downstream blocking operation
7379+
* (yielding an {@code InterruptedException}). It is recommended processing items
7380+
* that may take long time to be moved to another thread via {@link #observeOn} applied after
7381+
* {@code debounce} itself.
73607382
* <dl>
73617383
* <dt><b>Scheduler:</b></dt>
73627384
* <dd>You specify which {@link Scheduler} this operator will use.</dd>

0 commit comments

Comments
 (0)