https://kotlinlang.org logo
c

Colton Idle

02/09/2022, 2:56 PM
I'm using retrofit + moshi (and slacks eithernet too, but I'm putting that aside for right now) and working with a new api that'll always have this as a response wrapper essentially. What actually comes down inside of the nested
data
model is a model that is unique for each network call.
Copy code
{
  "ok": true,
  "data": {
    ...
  }
}
Should I try to use generics or a polymorphic type adapter? So something like
Copy code
suspend fun callOne(): BaseResponse<ActualOneResponse>
suspend fun callTwo(): BaseResponse<ActualTwoResponse>
or should I use
PolymorphicJsonAdapterFactory
and ask my backend to send back down a discriminator/labelKey?