Lakhdar Meftah
Lakhdar Meftah

Reputation: 51

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

Consider the following case:

Upvotes: 1

Views: 351

Answers (2)

Suhit Patil
Suhit Patil

Reputation: 12023

in Rxjava 2, you should use debounce operator which emit an item from an Observable if a particular timespan has passed without it emitting another item

.debounce(300, TimeUnit.MILLISECONDS)

Upvotes: 0

Lakhdar Meftah
Lakhdar Meftah

Reputation: 51

With rxjava2, You can use:

.throttleFirst(1, TimeUnit.SECONDS)

From the 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.

Upvotes: 1

Related Questions