image.png
# android
l
image.png
🧵 1
In order to use suspend functions retrofit 2.6.0
but I'm having problems creating the call adapter factory properly
My code
Untitled
v
I found this test really helpful: https://github.com/square/retrofit/blob/master/retrofit/src/test/java/retrofit2/KotlinSuspendTest.kt#L233 In your case, you will be delegating to the call obtained from the
nextCallAdapter::adapt
. And If I am reading it correctly, make sure that that
nextCallAdapter
uses
rawResultType
, and not the
returnType
, because you want the default call adapter to handle the
Call<T>
and not the
Call<Results<T>>
l
My main doubt is what do do on
adapt
to get
Result<T>
v
Wrap the call of
Call<T>
from the
nextCallAdapter::adapt
in an implementation of
Call<Results<T>>
where the
override fun enqueue()
will enqueue the adapted call and wrap into the
Results
and will pass the wrapped response to its callback. The rest of the
Call
methods can be delegated to the adapted
Call<T>
l
still can't compile tho
I'm sorry for my ignorance, I'm almost there
I'm wrapping the call, but the return types don't match and I still don't know how to communicate back the
Results<T>