aoriani
01/23/2018, 1:26 AMsealed class NetworkResource<out ResponseType, out ErrorType> {
class Loading<out ResponseType, out ErrorType> : NetworkResource<ResponseType, ErrorType>()
data class Success<out ResponseType, out ErrorType>(val response: ResponseType) : NetworkResource<ResponseType, ErrorType>()
data class Error<out ResponseType, out ErrorType>(val error: ErrorType) : NetworkResource<ResponseType, ErrorType>()
}
class NetworkObserver<ResponseType, ErrorType> : Observer<NetworkResource<ResponseType, ErrorType>> {}
When I use it from Java I'm getting incompatible types: <anonymous NetworkObserver<Object,String>> cannot be converted to Observer<NetworkResource<Object,String>>
. However if I am remove out
from NetworkResource it works for Java, but it messes type inference in Kotlin.@JvmSuppressWildcards
and looking at the bytecode do the job. I wonder if I am doing the right thing.