I’m all for Kotlin, but as others noted, your Kotlin example doesn’t do what it should, and it uses obsolete consumeEach. Consider something like using Timer instead:

fun CoroutineScope.debouncingActor(delay: Long) = actor<String> {
var t = Timer()

for (msg in channel) {
t = Timer()
t.schedule(delay) {

Solutions Architect @Depop, author of “Hands-on Design Patterns with Kotlin” book and “Web Development with Kotlin” course

Love podcasts or audiobooks? Learn on the go with our new app.