https://kotlinlang.org logo
#coroutines
Title
# coroutines
k

kevinherron

03/30/2020, 8:06 PM
is there a version of
Flow.debounce
that has a “failsafe” timeout - so that in the face of continuously emitted events at a rate faster than the debounce timeout something is at least occasionally emitted
t

tseisel

03/30/2020, 9:12 PM
Maybe the
sample
operator ? It emits at most once per period. I'm also trying to implement the
throttleLatest
operator from Rx, which is to me the best alternative to
debounce
k

kevinherron

03/30/2020, 9:59 PM
hmm. that might work for my case. thanks.
it’s not exactly the same because i won’t get the first event emitted until the sample period has elapsed, which in my originally scenario would be a bit longer than the timeout
t

tseisel

03/31/2020, 7:31 AM
Then you probably need `throttleLatest`: https://github.com/ReactiveX/RxJava/wiki/Filtering-Observables#throttlelatest Notice how the first element is emitted immediately.
k

kevinherron

03/31/2020, 12:41 PM
yes. doesn’t look like Flow has an equivalent right now
6 Views