https://kotlinlang.org logo
f

FranGSierra

10/17/2019, 10:25 AM
Hello! Fast question. It's possible to use Kotlin reflection in Kotlin Multiplatform? Only from common module, not on iOS or Android. Building at this moment a wrapper over Firebase Firestore and I want to cast a convert a class to a
Map<Field,Value>
for pass it to iOS library.
g

gildor

10/17/2019, 10:27 AM
No, reflections are available only on JVM
But probably kotlinx.serialization may help somehow in your case
f

FranGSierra

10/17/2019, 10:28 AM
Gonna check that then
g

gildor

10/17/2019, 10:30 AM
I’m not sure about particular approach, and it’s not exactly how it works, but it created to generate bytecode that provides mapping function for serialization formats (so probably output maybe also Map)
f

FranGSierra

10/17/2019, 10:36 AM
Great, gonna investigate about it 🙂 If it works as common serialization it should not be really hard. My other approach was going to have a
Serializable
interface applied to the models with a
toMap
fromMap
methods 😅
So if this works it will save me a lot of boilerplate 😄 thank you so much @gildor
3 Views