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

Sergio C.

08/22/2022, 1:56 PM
Hi everyone! Is there a way to reuse the continuation in
suspendCoroutine
block?
Copy code
suspendCoroutine { continuation -> }
I need to call continuation more than once but its throwing error
Copy code
java.lang.IllegalStateException: Already resumed
        at kotlin.coroutines.SafeContinuation.resumeWith(SafeContinuationJvm.kt:44)
Any way to bypass this?
c

Casey Brooks

08/22/2022, 1:57 PM
the continuation can only be used once. If you are trying to emit multiple values over time from a callback, you can use
callbackFlow
instead
s

Sergio C.

08/22/2022, 2:04 PM
Thanks! Will try that.
112 Views