reline
06/23/2021, 3:23 PMstartRequest() // third party api, async
// sometimes `channel.trySend()` is called before `receive()` is called
val response = channel.receive() // suspends indefinitely
I solved this issue using async
, is this the right approach? If I don't specify UNDISPATCHED
then it's still starting the request before receive()
is called
val job = async(start = CoroutineStart.UNDISPATCHED) {
channel.receive()
}
startRequest()
val response = job.await()