https://kotlinlang.org logo
Title
h

Heikki Rauhala

04/22/2021, 12:20 PM
What does the note
Note that the latest element is not emitted if it does not fit into the sampling window.
mean in the documentation of
Flow.sample
? https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/sample.html How can an element not fit in a sampling window? There will always be the next window, right? Unless the sampling is cancelled while there are un-emitted events in the latest window, but are there other situations where the latest event is not emitted?
u

uli

04/22/2021, 7:11 PM
I would say the last element is dropped if the stream terminates before the end of the sampling window. I.e. partial windows do not emit
h

Heikki Rauhala

04/26/2021, 1:46 PM
That's how I interpret it as well, and how you put it would indeed be a better way to document it.