This message was deleted.
# coroutines
s
This message was deleted.
z
When you declare a function as a
suspend
function, the compiler actually emits a function that always returns
Object
, and takes an extra
Continuation
parameter. The
Continuation
is basically just a callback that the function can use to return a result asynchronously.
k
What is the
delay(0)
for?
Also, where is the
launch
being run in and what is the body of
notifyVint
Ah, I assume notifyVint is automatically generated to do a post request. However, whatever library you are using doesn't support suspended functions. Instead, remove the
suspend
modifier and wrap any call
withContext(<http://Disparchers.IO|Disparchers.IO>){ ... }
k
How do you know suspend function is not suuported? @Kroppeb
z
Presumably, if they were supported, you wouldn't get that exception. Retrofit is a library with a similar API as this looks to be (define an interface, annotate the methods), and It had to explicitly add support for coroutines by looking for functions that had that last coroutine parameter, constructing a continuation appropriately, and handling the special return value.