Rx java:发出第一个项目,忽略接下来的项目 5 秒

Rx java: emits first item, ignore coming items for 5 seconds

考虑以下情况:

使用 rxjava2,您可以使用:

.throttleFirst(1, TimeUnit.SECONDS)

来自javadoc documentation

throttleFirst: Returns an Observable that emits only the first item emitted by the source ObservableSource during sequential time windows of a specified duration.

Rxjava 2, you should use debounce 运算符中,如果特定的时间跨度已经过去而没有发出另一个项目,则从 Observable 发出一个项目

.debounce(300, TimeUnit.MILLISECONDS)