Skip to content

Commit e6b852d

Browse files
Roman Petrenkoakarnokd
Roman Petrenko
authored andcommitted
Make it explicit that throttleWithTimout is an alias of debounce (#6049)
* Make it explicit that throttleWithTimout is an alias of debounce * feedback * fixed marble images
1 parent 102700c commit e6b852d

File tree

2 files changed

+44
-91
lines changed

2 files changed

+44
-91
lines changed

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

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8035,25 +8035,19 @@ public final <U> Flowable<T> debounce(Function<? super T, ? extends Publisher<U>
80358035
* will be emitted by the resulting Publisher.
80368036
* <p>
80378037
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
8038-
* <p>
8039-
* Information on debounce vs throttle:
8040-
* <ul>
8041-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
8042-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
8043-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
8044-
* </ul>
80458038
* <dl>
80468039
* <dt><b>Backpressure:</b></dt>
80478040
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
80488041
* <dt><b>Scheduler:</b></dt>
8049-
* <dd>This version of {@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
8042+
* <dd>{@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
80508043
* </dl>
80518044
*
80528045
* @param timeout
8053-
* the time each item has to be "the most recent" of those emitted by the source Publisher to
8054-
* ensure that it's not dropped
8046+
* the length of the window of time that must pass after the emission of an item from the source
8047+
* Publisher in which that Publisher emits no items in order for the item to be emitted by the
8048+
* resulting Publisher
80558049
* @param unit
8056-
* the {@link TimeUnit} for the timeout
8050+
* the unit of time for the specified {@code timeout}
80578051
* @return a Flowable that filters out items from the source Publisher that are too quickly followed by
80588052
* newer items
80598053
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
@@ -8076,13 +8070,6 @@ public final Flowable<T> debounce(long timeout, TimeUnit unit) {
80768070
* will be emitted by the resulting Publisher.
80778071
* <p>
80788072
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
8079-
* <p>
8080-
* Information on debounce vs throttle:
8081-
* <ul>
8082-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
8083-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
8084-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
8085-
* </ul>
80868073
* <dl>
80878074
* <dt><b>Backpressure:</b></dt>
80888075
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
@@ -8094,7 +8081,7 @@ public final Flowable<T> debounce(long timeout, TimeUnit unit) {
80948081
* the time each item has to be "the most recent" of those emitted by the source Publisher to
80958082
* ensure that it's not dropped
80968083
* @param unit
8097-
* the unit of time for the specified timeout
8084+
* the unit of time for the specified {@code timeout}
80988085
* @param scheduler
80998086
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
81008087
* item
@@ -15774,20 +15761,14 @@ public final Flowable<T> throttleLatest(long timeout, TimeUnit unit, Scheduler s
1577415761
}
1577515762

1577615763
/**
15777-
* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
15778-
* by another emitted item within a specified time window.
15764+
* Returns a Flowable that mirrors the source Publisher, except that it drops items emitted by the
15765+
* source Publisher that are followed by newer items before a timeout value expires. The timer resets on
15766+
* each emission (alias to {@link #debounce(long, TimeUnit)}).
1577915767
* <p>
15780-
* <em>Note:</em> If the source Publisher keeps emitting items more frequently than the length of the time
15781-
* window then no items will be emitted by the resulting Publisher.
15768+
* <em>Note:</em> If items keep being emitted by the source Publisher faster than the timeout then no items
15769+
* will be emitted by the resulting Publisher.
1578215770
* <p>
1578315771
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
15784-
* <p>
15785-
* Information on debounce vs throttle:
15786-
* <ul>
15787-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
15788-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
15789-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
15790-
* </ul>
1579115772
* <dl>
1579215773
* <dt><b>Backpressure:</b></dt>
1579315774
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
@@ -15800,8 +15781,9 @@ public final Flowable<T> throttleLatest(long timeout, TimeUnit unit, Scheduler s
1580015781
* Publisher in which that Publisher emits no items in order for the item to be emitted by the
1580115782
* resulting Publisher
1580215783
* @param unit
15803-
* the {@link TimeUnit} of {@code timeout}
15804-
* @return a Flowable that filters out items that are too quickly followed by newer items
15784+
* the unit of time for the specified {@code timeout}
15785+
* @return a Flowable that filters out items from the source Publisher that are too quickly followed by
15786+
* newer items
1580515787
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
1580615788
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a>
1580715789
* @see #debounce(long, TimeUnit)
@@ -15814,21 +15796,14 @@ public final Flowable<T> throttleWithTimeout(long timeout, TimeUnit unit) {
1581415796
}
1581515797

1581615798
/**
15817-
* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
15818-
* by another emitted item within a specified time window, where the time window is governed by a specified
15819-
* Scheduler.
15799+
* Returns a Flowable that mirrors the source Publisher, except that it drops items emitted by the
15800+
* source Publisher that are followed by newer items before a timeout value expires on a specified
15801+
* Scheduler. The timer resets on each emission (alias to {@link #debounce(long, TimeUnit, Scheduler)}).
1582015802
* <p>
15821-
* <em>Note:</em> If the source Publisher keeps emitting items more frequently than the length of the time
15822-
* window then no items will be emitted by the resulting Publisher.
15803+
* <em>Note:</em> If items keep being emitted by the source Publisher faster than the timeout then no items
15804+
* will be emitted by the resulting Publisher.
1582315805
* <p>
1582415806
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.s.png" alt="">
15825-
* <p>
15826-
* Information on debounce vs throttle:
15827-
* <ul>
15828-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
15829-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
15830-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
15831-
* </ul>
1583215807
* <dl>
1583315808
* <dt><b>Backpressure:</b></dt>
1583415809
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
@@ -15841,11 +15816,12 @@ public final Flowable<T> throttleWithTimeout(long timeout, TimeUnit unit) {
1584115816
* Publisher in which that Publisher emits no items in order for the item to be emitted by the
1584215817
* resulting Publisher
1584315818
* @param unit
15844-
* the {@link TimeUnit} of {@code timeout}
15819+
* the unit of time for the specified {@code timeout}
1584515820
* @param scheduler
1584615821
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
1584715822
* item
15848-
* @return a Flowable that filters out items that are too quickly followed by newer items
15823+
* @return a Flowable that filters out items from the source Publisher that are too quickly followed by
15824+
* newer items
1584915825
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
1585015826
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a>
1585115827
* @see #debounce(long, TimeUnit, Scheduler)

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

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7196,23 +7196,17 @@ public final <U> Observable<T> debounce(Function<? super T, ? extends Observable
71967196
* will be emitted by the resulting ObservableSource.
71977197
* <p>
71987198
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
7199-
* <p>
7200-
* Information on debounce vs throttle:
7201-
* <ul>
7202-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
7203-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
7204-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
7205-
* </ul>
72067199
* <dl>
72077200
* <dt><b>Scheduler:</b></dt>
7208-
* <dd>This version of {@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
7201+
* <dd>{@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
72097202
* </dl>
72107203
*
72117204
* @param timeout
7212-
* the time each item has to be "the most recent" of those emitted by the source ObservableSource to
7213-
* ensure that it's not dropped
7205+
* the length of the window of time that must pass after the emission of an item from the source
7206+
* ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the
7207+
* resulting ObservableSource
72147208
* @param unit
7215-
* the {@link TimeUnit} for the timeout
7209+
* the unit of time for the specified {@code timeout}
72167210
* @return an Observable that filters out items from the source ObservableSource that are too quickly followed by
72177211
* newer items
72187212
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
@@ -7233,13 +7227,6 @@ public final Observable<T> debounce(long timeout, TimeUnit unit) {
72337227
* will be emitted by the resulting ObservableSource.
72347228
* <p>
72357229
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.s.png" alt="">
7236-
* <p>
7237-
* Information on debounce vs throttle:
7238-
* <ul>
7239-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
7240-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
7241-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
7242-
* </ul>
72437230
* <dl>
72447231
* <dt><b>Scheduler:</b></dt>
72457232
* <dd>You specify which {@link Scheduler} this operator will use.</dd>
@@ -7249,7 +7236,7 @@ public final Observable<T> debounce(long timeout, TimeUnit unit) {
72497236
* the time each item has to be "the most recent" of those emitted by the source ObservableSource to
72507237
* ensure that it's not dropped
72517238
* @param unit
7252-
* the unit of time for the specified timeout
7239+
* the unit of time for the specified {@code timeout}
72537240
* @param scheduler
72547241
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
72557242
* item
@@ -13180,20 +13167,15 @@ public final Observable<T> throttleLatest(long timeout, TimeUnit unit, Scheduler
1318013167
}
1318113168

1318213169
/**
13183-
* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
13184-
* by another emitted item within a specified time window.
13170+
* Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the
13171+
* source ObservableSource that are followed by newer items before a timeout value expires. The timer resets on
13172+
* each emission (alias to {@link #debounce(long, TimeUnit, Scheduler)}).
1318513173
* <p>
13186-
* <em>Note:</em> If the source ObservableSource keeps emitting items more frequently than the length of the time
13187-
* window then no items will be emitted by the resulting ObservableSource.
13174+
* <em>Note:</em> If items keep being emitted by the source ObservableSource faster than the timeout then no items
13175+
* will be emitted by the resulting ObservableSource.
1318813176
* <p>
1318913177
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
1319013178
* <p>
13191-
* Information on debounce vs throttle:
13192-
* <ul>
13193-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
13194-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
13195-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
13196-
* </ul>
1319713179
* <dl>
1319813180
* <dt><b>Scheduler:</b></dt>
1319913181
* <dd>{@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
@@ -13204,8 +13186,9 @@ public final Observable<T> throttleLatest(long timeout, TimeUnit unit, Scheduler
1320413186
* ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the
1320513187
* resulting ObservableSource
1320613188
* @param unit
13207-
* the {@link TimeUnit} of {@code timeout}
13208-
* @return an Observable that filters out items that are too quickly followed by newer items
13189+
* the unit of time for the specified {@code timeout}
13190+
* @return an Observable that filters out items from the source ObservableSource that are too quickly followed by
13191+
* newer items
1320913192
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
1321013193
* @see #debounce(long, TimeUnit)
1321113194
*/
@@ -13216,21 +13199,14 @@ public final Observable<T> throttleWithTimeout(long timeout, TimeUnit unit) {
1321613199
}
1321713200

1321813201
/**
13219-
* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
13220-
* by another emitted item within a specified time window, where the time window is governed by a specified
13221-
* Scheduler.
13202+
* Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the
13203+
* source ObservableSource that are followed by newer items before a timeout value expires on a specified
13204+
* Scheduler. The timer resets on each emission (Alias to {@link #debounce(long, TimeUnit, Scheduler)}).
1322213205
* <p>
13223-
* <em>Note:</em> If the source ObservableSource keeps emitting items more frequently than the length of the time
13224-
* window then no items will be emitted by the resulting ObservableSource.
13206+
* <em>Note:</em> If items keep being emitted by the source ObservableSource faster than the timeout then no items
13207+
* will be emitted by the resulting ObservableSource.
1322513208
* <p>
1322613209
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.s.png" alt="">
13227-
* <p>
13228-
* Information on debounce vs throttle:
13229-
* <ul>
13230-
* <li><a href="http://drupalmotion.com/article/debounce-and-throttle-visual-explanation">Debounce and Throttle: visual explanation</a></li>
13231-
* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
13232-
* <li><a href="http://www.illyriad.co.uk/blog/index.php/2011/09/javascript-dont-spam-your-server-debounce-and-throttle/">Javascript - don't spam your server: debounce and throttle</a></li>
13233-
* </ul>
1323413210
* <dl>
1323513211
* <dt><b>Scheduler:</b></dt>
1323613212
* <dd>You specify which {@link Scheduler} this operator will use.</dd>
@@ -13241,11 +13217,12 @@ public final Observable<T> throttleWithTimeout(long timeout, TimeUnit unit) {
1324113217
* ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the
1324213218
* resulting ObservableSource
1324313219
* @param unit
13244-
* the {@link TimeUnit} of {@code timeout}
13220+
* the unit of time for the specified {@code timeout}
1324513221
* @param scheduler
1324613222
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
1324713223
* item
13248-
* @return an Observable that filters out items that are too quickly followed by newer items
13224+
* @return an Observable that filters out items from the source ObservableSource that are too quickly followed by
13225+
* newer items
1324913226
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
1325013227
* @see #debounce(long, TimeUnit, Scheduler)
1325113228
*/

0 commit comments

Comments
 (0)