Matej Drobnič
07/28/2019, 6:58 PMImplicitReflectionSerializer
?
I want to create generic method to send data classes through Websocket. At the moment I have this:
suspend fun <T> send(item: T, serializer: KSerializer<T>) {
// TODO
}
but it is a bit awkward to always pass the serializer. Since I'm always sending data classes which do not support extension, runtime type is not important to me, I would be fine with just detecting the compile-time type.sandwwraith
07/29/2019, 9:05 AMreified
will give you KClass only, and to obtain KSerializer from KClass you'll need some reflection. For non-generic data classes it will work OK on JVM and JS, but on Native it is not available completely