kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Add argument to sample to sample at the start of a flow instead of the end?
trafficstars
Use case
I have a stream of items coming in fairly quickly (30 per second) and according to my PMs I only need to grab the first item, every 5 seconds. This is pretty simple with sample(5.seconds), but I always have to wait at least 5 seconds before I get the first element. It'd be awesome in order to control that I want the element from the beginning of the 5 seconds instead of the last element of the 5 seconds.
The Shape of the API I feel like an argument would suffice, but maybe an enum or something of what type of sampling is being done. Thank you!