Hi all! I really need to do the following behavior...
# coroutines
d
Hi all! I really need to do the following behavior. There is some source of events, for example, onСlick(), which emits items with time intervals (for example, the user clicks the button very quickly). I need to subscribe to it and collect all items with a set time interval, for example 2 sec. How can this be done with Flow API?
o
Copy code
val deadline = Instant.now().plusSeconds(2)
val items = flow.takeWhile { Instant.now() < deadline }.toList()
?
or maybe I don't understand exactly what your data looks like
d
No, I just need to buffer all sent items, like in BroadcastChannel, but using flow
e
like this? https://pl.kotl.in/pORqFs8VL (just hacked together, not very tested)