gildor / kotlin-coroutines-retrofit

Kotlin Coroutines await() extension for Retrofit Call
Apache License 2.0
848 stars 64 forks source link

fun okhttp3.Call.await() = TODO() ? #11

Closed jmfayard closed 7 years ago

jmfayard commented 7 years ago

Hello

I just gave a try to your library and found it very handy.

I often have to mix retofit and okhttp3 calls inside the same project and I was thinking it would make a lot of sense to have those await extension functions for okhttp as well.

Since retrofit requires okhttp3, that would not add a new dependancy for the users of the library

A use case would be

val retrofitData = api.getData().await()
val okRequest = createRequest(retrofitData.url)
val okData = okClient.newCall(okRequest).await()
gildor commented 7 years ago

@jmfayard Hi. I had an idea to support okhttp too, but I think it should be separate library because it can be used without retrofit dependency. Do you have any good use cases for coroutines in OkHttp instead Call<T>.await()?

jmfayard commented 7 years ago

retrofit without any additional dependancy is actually a lean library. How many people would use both okhttp and your library and would mind to have a dependancy to retrofit ? IMHO not enough that you should care about it, at least for now.

As for the API, okhttp3.Call and retrofit2.Call are basically identical, so I guess the same would work

gildor commented 7 years ago

No, I'm talking about people who want to use okhttp without retrofit and use coroutines extensions

gildor commented 7 years ago

@jmfayard I've started work on OkHttp, and for now, I see the only case is await() for Call Library not published yet, but that is only one extension function - https://github.com/gildor/kotlin-coroutines-okhttp

gildor commented 7 years ago

Closing task. Please create issue about OkHttp there https://github.com/gildor/kotlin-coroutines-okhttp