elizarov
03/13/2017, 5:28 PMsuspend fun Call.await(): Response = suspendCancellableCoroutine { cont ->
enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) { cont.resume(response) }
override fun onFailure(call: Call, e: IOException) { cont.resumeWithException(e) }
})
cont.invokeOnCompletion { cancel() }
}
Does one really needs a library for 7 lines of code?