What's the best way to pass along a handle to resp...
# coroutines
r
What's the best way to pass along a handle to respond to a suspending function? Aka
Copy code
kotlin
suspend fun sendingRequestToStatemachine(reqData: String): {
  suspendCancellableCoroutine { cont ->
    machine.processEvent(Request(reqData, cont))
  }
}
d
I'm not entirely sure I understand your question. You use
suspendCancellableCoroutine
if you need to bridge coroutine code with asynchronous callback code. When you call
suspendCancellableCoroutine
, you become responsible to ensure that the continuation is invoked at some point in the future.