https://kotlinlang.org logo
#coroutines
Title
# coroutines
g

gildor

07/04/2017, 5:26 PM
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

louiscad

07/05/2017, 10:10 AM
@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

gildor

07/05/2017, 10:12 AM
you can wrap each call to
async(CommonPool) { request.await() }
you can even create extension function for that
l

louiscad

07/05/2017, 10:14 AM
Would work with
async(UI)
too on Android, right?
g

gildor

07/05/2017, 10:17 AM
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
4 Views