Just released Kotlin Coroutines for Retrofit v0.6....
# coroutines
g
Just released Kotlin Coroutines for Retrofit v0.6.0 - https://github.com/gildor/kotlin-coroutines-retrofit/releases/tag/v0.6.0 available on jcenter and maven central it’s supposed to be the last release before merge to kotlinx.coroutines integrations. If somebody has any ideas about API changes before that, please message me or PR.
đź‘Ť 3
l
@gildor: Is there a way to start requests in parallel from the same coroutines context like it is possible in the following library? https://github.com/tinsukE/retrofit-coroutines#but-why
g
you can wrap each call to
async(CommonPool) { request.await() }
you can even create extension function for that
l
Would work with
async(UI)
too on Android, right?
g
There are no blocking calls, so should work
I thought about call adapter that returns suspend results, but after all I decided that it requires change of retrofit interface and doesn’t worth it.
You can create extension function to do that
Copy code
suspend fun Call<T>.awaitAsync(contet: Context) = async(Context) { await() }
(didn’t check the code, just an example)
also it should be more flexible, because you can pass particular context for each call