reactormonk
01/18/2024, 12:54 PMkotlin
suspend fun sendingRequestToStatemachine(reqData: String): {
suspendCancellableCoroutine { cont ->
machine.processEvent(Request(reqData, cont))
}
}
Daniel Pitts
01/18/2024, 4:03 PMsuspendCancellableCoroutine
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.