Joan Colmenero
10/19/2019, 4:07 PMResultWrapperT
from CallT
but now reading this answer [1] from stackoverflow then I realized that if I'm using suspended fun
I do not have to add the CallT
so, how do I do the change now? I was using this method :
fun <reified T:Any> execute(function: () -> Call<T>): ResultWrapperT =
try {
when (T::class) {
Unit::class -> function().execute().let {
ResultWrapper.Success(Unit as T)
}
else -> function().execute().body()?.let {
ResultWrapper.Success(it)
} ?: ResultWrapper.Error(Exception("no body there"))
}
} catch (e: Exception) {
ResultWrapper.Exception(e)
}
Any idea? The problem now is that as it's not a CallT
I do not have the execute()
method...
[1] : https://stackoverflow.com/a/57810074/4329781Kroppeb
10/19/2019, 4:09 PMexecute()
?Joan Colmenero
10/19/2019, 4:10 PMKroppeb
10/19/2019, 4:11 PMfunction
now returns T?
. It might also be useful to constrain T to be non nullable: <reified T:Any>
Joan Colmenero
10/19/2019, 4:15 PM@GET("/") suspended fun pew(something) : ResultWrapper<POJO>
but was not working, then the problem is that I can not do that... So I have to do like a "migration" or whatever you want to call from @GET("/") suspended fun pew(something) : POJO
and then change it to ResultWrapper<POJO>
is it possible?Kroppeb
10/19/2019, 9:25 PM