aishwaryabhishek3
02/13/2026, 7:32 AMoverride suspend fun execute() {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
suspendCoroutine { cont ->
SDK.submitData(
object : Callback<SubmitResponse> {
override fun onSuccess(response: SubmitResponse?) {
cont.resume()
}
override fun onError(exception: Exception?) {
cont.resumeWithException(exception)
}
}
)
}
}
}Wout Werkman
02/13/2026, 11:46 AMsuspendCoroutine here instead of suspendCancellableCoroutine. I believe the latter should workphldavies
02/13/2026, 11:53 AMsuspend fun execute(): SubmitResponse? {
val result = CompletableDeferred<SubmitResponse?>()
SDK.submitData(object : Callback<SubmitResponse> {
override fun onSuccess(response: SubmitResponse?) {
result.complete(response)
}
override fun onError(exception: Exception) {
result.completeExceptionally(exception)
}
})
return withTimeoutOrNull(500.milliseconds) { result.await() }
}
https://pl.kotl.in/HePwqeOF7