You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, as mentioned in #11 , isReturnTypeList can work with any return type which contains java.util.List.
However, this approach has some issues:
Incorrect if the return type is something like this: Foo<Bar<Baz<List<Something>>>
Cannot work with other collection types like Set, Array.
I tried an update like this:
privatefunisMethodWithListReturnValue(method:Method): Boolean {
if (method.returnType.isArray) {
returntrue
}
val genericReturnType = method.genericReturnType as?ParameterizedType?:returnfalsereturn isArrayOrCollectionClass(genericReturnType.rawType.typeName)
}
However, this doesn't work if List-type is the secondary type like: Flow<List<Something>>.
If we extract secondary type from Flow like what we did with Continuation for suspend method, we cannot guarantee whether the list is hidden under the third type like Flow<Resource<List<Type>>>.
The text was updated successfully, but these errors were encountered:
Another approach is to stop supporting too many types. We can limit to only suspend or normal function which returns List or Collection.
IMO, if a dev wants to support Flow for API, he/she can easily create a repository class. The API just does request and response data, not handle the other things (Single responsibility principle).
I definitely vote for this. @theapache64 What do you think?
Sorry for the late reply. I somehow missed this issue.
Incorrect if the return type is something like this: Foo<Bar<Baz<List>>
As of now, technically, retrosheet can only return an Object or List<Object>. so the above given generic wouldn't be technically possible at all. This means, even if we write support for that, that case won't occur.
If we extract secondary type from Flow like what ...
If the consumer wants to use Flow, Resource, or any other custom type. They'll have to write custom retrofit call adapters for that. I think this doesn't come under retrosheet.
Currently, as mentioned in #11 ,
isReturnTypeList
can work with any return type which containsjava.util.List
.However, this approach has some issues:
Foo<Bar<Baz<List<Something>>>
Set
, Array.I tried an update like this:
However, this doesn't work if
List
-type is the secondary type like:Flow<List<Something>>
.If we extract secondary type from
Flow
like what we did withContinuation
for suspend method, we cannot guarantee whether the list is hidden under the third type likeFlow<Resource<List<Type>>>
.The text was updated successfully, but these errors were encountered: