sample
Returns a flow that emits only the latest value emitted by the original flow during the given sampling period.
Example:
flow {
repeat(10) {
emit(it)
delay(110)
}
}.sample(200)Content copied to clipboard
produces the following emissions
1, 3, 5, 7, 9Content copied to clipboard
Note that the latest element is not emitted if it does not fit into the sampling window.
Returns a flow that emits only the latest value emitted by the original flow during the given sampling period.
Example:
flow {
repeat(10) {
emit(it)
delay(110.milliseconds)
}
}.sample(200.milliseconds)Content copied to clipboard
produces the following emissions
1, 3, 5, 7, 9Content copied to clipboard
Note that the latest element is not emitted if it does not fit into the sampling window.