dave08
12/01/2017, 10:59 AMfun runJob() = launch(IO) {
if (isActive) doStuff()
if (isActive) doOtherStuff()
if (isActive) doEvenMoreStuff()
}
val channel = Channel(Channel.Conflated)
var currJob: Job? = null
channel.consumeEach { currJob?.cancel(); currJob = runJob() }
// Send new job
channel.offer(Unit)
What about this (im not on my computer, so excuse if any mistakes.. its the idea though...) @Paul Woitaschek