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

Tran Thang

01/12/2023, 6:49 AM
Hi guys, anyone help me what the difference between suspendCoroutine and suspendCancellableCoroutine?
f

franztesca

01/12/2023, 7:35 AM
suspendCoroutine is the primitive baked in the language (kotlin.coroutines). suspendCancellableCoroutine is the primitive offered by the coroutines library kotlinx.coroutines, which interoperates with the rest (job, dispatchers, ...) to support prompt cancellation. If you want to write a component to be used with the kotlinx library (most likely the case), use the cancellable version.