that’s the thing I don’t. If I remove all the `wit...
# coroutines
j
that’s the thing I don’t. If I remove all the
withContext
and leave the
launch
as it is, and with the base context defined as Main + job it works just fine
d
Because you're probably using a library that originally returns a callback (with its own thread pool for running the request) and await seems to be adapting that callback using
suspendCallableCoroutine { }
, which will suspend until the callback is called. Then you don't need
withContext
at all.
a
launch does not block the main thread, that's why you don't get an exception
d
Not true if launch uses the Main dispatcher and you run blocking code on it...
For real blocking code withContext with IO or Default or custom dispatcher is needed.
✔️ 1