reactormonk
05/31/2023, 6:55 PMreturn withTimeout(1000L) {
suspendCancellableCoroutine { continuation ->
mOnReceiveRfmUltralightCmdListener = { isSuc, data ->
if (!isSuc) {
continuation.resumeWithException(
CardNoResponseException()
)
} else {
continuation.resume(data)
}
}
continuation.invokeOnCancellation {
mOnReceiveRfmUltralightCmdListener = null
}
writeToReader()
}
}
Where writeToReader() is a suspend function - should I just use a scope.launch there?mkrussel
06/01/2023, 11:51 AMwriteToReader out of the suspendCancellableCoroutine unless that is what triggers the work callback to complete.
In that case I would think that the suspendCancellableCoroutine should get moved into the suspending writeToReader, ideally not needing a member variable for the listener. It should then be returning the data, but a function called writeToReader returning data is strange.reactormonk
06/01/2023, 4:23 PM