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?
答案 0 :(得分:9)
根据rx-java 1.0.x源代码,它是一样的,因为throttleLast()只是调用sample():
https://github.com/ReactiveX/RxJava/blob/v1.0.16/src/main/java/rx/Observable.java#L8819-L8821