kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Add argument to sample to sample at the start of a flow instead of the end?

Open ColtonIdle opened this issue 1 year ago • 5 comments
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!

ColtonIdle avatar Aug 31 '24 00:08 ColtonIdle