<@U0B98KWF4> is it possible to create custom room...
# android-architecture
f
@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
Consider to serialize/deserialize the sealed class. kotlinx.serialization can esiliy serialize/deserialize a sealed class.
f
This wasn't my question, sorry
p
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
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()
f
That's what I'm doing currently