https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

cbruegg

02/25/2019, 5:14 PM
For such cases, I usually do something like this:
Copy code
var delayedJob: Job? = null

fun onEvent() {
  delayedJob?.cancel()
  delayedJob = launch {
    delay(1000)
    // Do stuff
  }
}
n

Nikky

02/25/2019, 8:13 PM
thats what i came up with as well, pretty much exactly the same
c

cbruegg

02/25/2019, 8:14 PM
It's simple and it works, so good enough for my use cases
2 Views