Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

throttleLast vs sample in RxJava

Tags:

rx-java

Are there any difference between throttleLast(long, TimeUnit) and sample(long, TimeUnit) of Observable?

Both emit the last item of interval, so they are the same method to me.

If there are differences, what would be the better use case?

like image 947
otal Avatar asked Jul 11 '16 21:07

otal


1 Answers

According to the rx-java 1.0.x source code, it is the same thing, as throttleLast() is just calling sample():

https://github.com/ReactiveX/RxJava/blob/v1.0.16/src/main/java/rx/Observable.java#L8819-L8821

like image 89
yurgis Avatar answered Sep 26 '22 23:09

yurgis