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

kingsley

03/20/2017, 8:25 PM
Copy code
private val callbackContext = ...

fun request(...) {
  pendingJob?.cancel()
  
  pendingJob = launch(callbackContext) {
    delay(DEBOUNCE_PERIOD)
    ...
    suspendingFun()
    ...
  }
}

suspend fun suspendingFun(...) {
  someApi().await()
  ...
}
This used to work fine in version 0.12. Currently on version 0.14, the launch block doesn't seem to execute more than once anymore. Not sure what the problem is
e

elizarov

03/21/2017, 6:07 AM
Can you produce a self-contained piece of code that reproduces the problem?
k

kingsley

03/25/2017, 11:57 AM
Hi @elizarov, I haven't been able to reproduce a self contained code. I'm guessing there was probably a change in how cancellations work somewhere along the line (can't find anything regarding that in the changelog though). So far, it works on 0.12, but not in any of the 0.14 variants, so I'm sticking with 0.12 till when I'm able to look closely into what exactly the problem might be.
e

elizarov

03/25/2017, 3:12 PM
I don't think anything cancellation-related has changed between 0.12 and 0.14
5 Views