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

Thomas

05/17/2019, 4:04 PM
Could an operator like the following be added to Flow? The debounce operator is already added, but I need one with a different timeout depending on the item. It shouldn’t be too difficult to modify the current operator to add this. I can explain my use case for this operator if needed.
Copy code
fun <T> Flow<T>.debounce(timeoutMillis: (T) -> Long): Flow<T>
👍🏻 3
o

octylFractal

05/17/2019, 4:10 PM
how would that differ from
flow.filter(pred).debounce(timeout)
?
t

Thomas

05/17/2019, 4:17 PM
@octylFractal if the predicate returns true for an item the timeout should be 0 (for that item only) instead of the given
timeoutMillis
. Anyway, I changed the operator in my original message to something which makes more sense. This allows you to use a different timeout depending on the item.
2 Views