Hey all! Is there a way to run a Coroutine inside ...
# announcements
h
Hey all! Is there a way to run a Coroutine inside a lambda function?
I'm creating this lambda inside a
suspend
function
d
...yes, same way you'd run a coroutine anywhere else - using
launch
. Have you tried it and come up against difficulties?
h
It cannot access
launch
inside the lambda function
when I try to run my suspend function from here it generates the following error:
Suspension functions can be called only within coroutine body
i
Make your lambda
suspend
?
h
how can I do that? The lambda is accepted as an argument to a function in a 3rd party lib
right now I've to explicitly pass a
CoroutineScope
to run the coroutine. But would like to avoid that if possible
i
Ah, you failed to mention that you didn't control both sides. Passing in the correct scope seems like your best option then
­čĹŹ 1
h
Gotcha, thanks for the help guys