@yigit is it possible to create custom room types like rxjava3's flowables/observable/singe, paging's data source etc..
I want room to return a type of my sealed class result, just like you can do with retrofit?
p
Pavel Sidyakin
01/18/2021, 1:44 PM
Consider to serialize/deserialize the sealed class. kotlinx.serialization can esiliy serialize/deserialize a sealed class.
f
FunkyMuse
01/18/2021, 1:47 PM
This wasn't my question, sorry
p
Pavel Sidyakin
01/18/2021, 2:01 PM
The only way to add a custom type to Room is TypeConverter.
In case of a sealed class you can create the TypeConverter for your class and use kotlinx serialization inside (because it supports a sealed class serialization out-of-box).
j
Javier
01/18/2021, 2:02 PM
But he doesnt want a new type
he wants wrap the type, like kotlin flow or rxjava
he doesnt want to save the sealed class directly, he wants to recover the current type and based on some exceptions, map it to a sealed class
currently you only can do something like dao.getSometing().someFunWhichCatchExceptionsAndTransformToSealedClass()