haroldadmin
08/12/2019, 5:56 AM@GET("/")
suspend fun getSomething(): MySealedClass<SuccessType, ErrorType>
On a Reddit discussion thread, Jake left some instructions on how this could be done: https://www.reddit.com/r/androiddev/comments/c6m3yv/network_request_wrapper_extension_for_retrofit_26
Here's the relevant part:
I am unable to figure out how to do the delegation part. I have a call of the typewill ask Retrofit for a CallAdapter to handlesuspend fun whatever(): Whatever. Knowing this, you can register aCall<Whatever>which looks forCallAdapter.Factory, delegates to the built-in factory forCall<YourSealedClass<BodyType>>, and then wraps the value inCall<BodyType>. This will allowYourSealedClassto work–no extension needed.suspend fun whatever(): YourSealedClass<Whatever>
Call<MySealedClass<SuccessType, E>>, and need to find a delegate which can adapt Call<SuccessType>. More specifically, I can not figure out how to create a Parameterized Type Token for Call<SuccessType> so that I can pass it to retrofit to find the delegated adapter for me.
I would really appreciate some help with this.