Hi, is there a way to have a `ReceiveChannel` / ac...
# coroutines
l
Hi, is there a way to have a
ReceiveChannel
/ actor that cancels the work done for a value if a new one is received? My goal is to perform a computation for the latest received value and drop any in progress work.
j
Copy code
val actor = actor<Int> {

  var job: Job? = null

  consumeEach {
    job?.cancel()
    job = launch(coroutineContext) {
      // TODO
    }
  }
}
Would it behave as you want ?
l
@Jonathan Yes! Thank you! 🙂