withoutclass
Jonathan
fun <E> ReceiveChannel<E>.debounce(duration: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ReceiveChannel<E> = produce { var job: Job? = null consumeEach { element -> job?.cancel() job = launch(coroutineContext) { delay(duration, timeUnit) send(element) } } job?.join() }
dave08
A modern programming language that makes developers happier.