Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it explicit that throttleWithTimout is an alias of debounce #6049

Merged
merged 3 commits into from
Jun 18, 2018

Conversation

romanzes
Copy link

@romanzes romanzes commented Jun 17, 2018

The documentation implies that these two methods are somewhat different. Fixing that confusion, as discussed in #6043:

  • Made the descriptions of these methods the same
  • Mentioned that it is an alias in the first paragraphs of throttleWithTimeout javadoc comments
  • Removed the links to third-party websites

* @param scheduler
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
* item
* @return a Flowable that filters out items from the source Publisher that are too quickly followed by
* newer items
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a>
* @see #throttleWithTimeout(long, TimeUnit, Scheduler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep these for clarity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -15774,34 +15761,31 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
}

/**
* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
* by another emitted item within a specified time window.
* Alias to {@link #debounce(long, TimeUnit)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the description as the first sentence and these as the second one or as a braced comment on the first sentence.

Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
by another emitted item within a specified time window (alias to {@link #debounce(long, TimeUnit)}).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
* <dd>This version of {@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this is too verbose. Reverted it here and also changed javadoc for debounce which also had this unnecessary verbosity.

* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
* by another emitted item within a specified time window, where the time window is governed by a specified
* Scheduler.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the original first sentence, similarly as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved the mention of alias to the end of the sentence

@@ -13180,32 +13167,30 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
}

/**
* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
* by another emitted item within a specified time window.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same situation, please keep the first sentence and mention it being an alias later.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
* by another emitted item within a specified time window, where the time window is governed by a specified
* Scheduler.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the original sentence first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @param scheduler
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
* item
* @return an Observable that filters out items from the source ObservableSource that are too quickly followed by
* newer items
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
* @see #throttleWithTimeout(long, TimeUnit, Scheduler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the see reference.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@akarnokd akarnokd added this to the 2.2 milestone Jun 17, 2018
* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the marbles as they were because they contain the operator name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, done. However, I don't understand why there should be two copies of the same image with different names. Take a look at the javadoc for share() operator: it is an alias for publish().refCount() and it has a link to https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/publishRefCount.png.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of copy-paste and outdated diagrams to fix because of wrong operator names. At least these were named according to their operator. Leaving it as is the simpler task as the alternative, combining the two image by listning both names would be a different undertaking.

* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.s.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the original marble here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
* <dd>This version of {@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to change this line, also the method name is incorrect: https://travis-ci.org/ReactiveX/RxJava/builds/393285007#L649

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, fixed

@akarnokd
Copy link
Member

Build warnings: please avoid dangling <p> tags: https://travis-ci.org/ReactiveX/RxJava/builds/393285007#L476

Copy link
Author

@romanzes romanzes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akarnokd thanks for your feedback. Please take a look again.

* @param scheduler
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
* item
* @return a Flowable that filters out items from the source Publisher that are too quickly followed by
* newer items
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a>
* @see #throttleWithTimeout(long, TimeUnit, Scheduler)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -15774,34 +15761,31 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
}

/**
* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
* by another emitted item within a specified time window.
* Alias to {@link #debounce(long, TimeUnit)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, done. However, I don't understand why there should be two copies of the same image with different names. Take a look at the javadoc for share() operator: it is an alias for publish().refCount() and it has a link to https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/publishRefCount.png.

* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>This operator does not support backpressure as it uses time to control data flow.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
* <dd>This version of {@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this is too verbose. Reverted it here and also changed javadoc for debounce which also had this unnecessary verbosity.

* Returns a Flowable that only emits those items emitted by the source Publisher that are not followed
* by another emitted item within a specified time window, where the time window is governed by a specified
* Scheduler.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved the mention of alias to the end of the sentence

* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.s.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @param scheduler
* the {@link Scheduler} to use internally to manage the timers that handle the timeout for each
* item
* @return an Observable that filters out items from the source ObservableSource that are too quickly followed by
* newer items
* @see <a href="http://reactivex.io/documentation/operators/debounce.html">ReactiveX operators documentation: Debounce</a>
* @see #throttleWithTimeout(long, TimeUnit, Scheduler)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -13180,32 +13167,30 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
}

/**
* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
* by another emitted item within a specified time window.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code throttleWithTimeout} operates by default on the {@code computation} {@link Scheduler}.</dd>
* <dd>This version of {@code debounce} operates by default on the {@code computation} {@link Scheduler}.</dd>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, fixed

* Returns an Observable that only emits those items emitted by the source ObservableSource that are not followed
* by another emitted item within a specified time window, where the time window is governed by a specified
* Scheduler.
* Alias to {@link #debounce(long, TimeUnit, Scheduler)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@codecov
Copy link

codecov bot commented Jun 17, 2018

Codecov Report

Merging #6049 into 2.x will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6049      +/-   ##
============================================
- Coverage     98.27%   98.25%   -0.03%     
- Complexity     6190     6192       +2     
============================================
  Files           666      666              
  Lines         44802    44802              
  Branches       6206     6206              
============================================
- Hits          44030    44019      -11     
- Misses          236      239       +3     
- Partials        536      544       +8
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Flowable.java 100% <ø> (ø) 564 <0> (ø) ⬇️
src/main/java/io/reactivex/Observable.java 100% <ø> (ø) 539 <0> (ø) ⬇️
...reactivex/internal/operators/single/SingleAmb.java 96.36% <0%> (-3.64%) 9% <0%> (-1%)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 92.27% <0%> (-3.39%) 2% <0%> (ø)
.../operators/observable/ObservableFlatMapSingle.java 88.8% <0%> (-2.99%) 2% <0%> (ø)
...ternal/operators/completable/CompletableMerge.java 96.42% <0%> (-2.39%) 2% <0%> (ø)
...rnal/operators/flowable/FlowableFlatMapSingle.java 94.56% <0%> (-2.18%) 2% <0%> (ø)
.../io/reactivex/internal/schedulers/IoScheduler.java 89.24% <0%> (-2.16%) 9% <0%> (ø)
.../io/reactivex/disposables/CompositeDisposable.java 98.14% <0%> (-1.86%) 39% <0%> (-1%)
...perators/mixed/ObservableConcatMapCompletable.java 98.49% <0%> (-1.51%) 3% <0%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65c4956...4dc8b76. Read the comment docs.

Copy link
Member

@akarnokd akarnokd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done, some marble image references are wrong.

* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use throttleWithTimeout image.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
* <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>
* </ul>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be throttleWithTimeout.s.png.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
* <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>
* </ul>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be throttleWithTimeout.s.png.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't notice there are two versions. Fixed.

@@ -13259,7 +13236,7 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
* Returns an Observable that emits records of the time interval between consecutive items emitted by the
* source ObservableSource.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a mistake as this is the docs for timeInterval.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, shouldn't have worked on it at 2am... Done.

Copy link
Author

@romanzes romanzes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for my inattentiveness. Should be fine now :)

* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
* <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>
* </ul>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't notice there are two versions. Fixed.

* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/debounce.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* <li><a href="http://unscriptable.com/2009/03/20/debouncing-javascript-methods/">Debouncing: javascript methods</a></li>
* <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>
* </ul>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -13259,7 +13236,7 @@ public final Completable switchMapCompletableDelayError(@NonNull Function<? supe
* Returns an Observable that emits records of the time interval between consecutive items emitted by the
* source ObservableSource.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timeInterval.png" alt="">
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/throttleWithTimeout.png" alt="">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, shouldn't have worked on it at 2am... Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants