Thread
#serialization
    w

    Waqas Tahir

    1 year ago
    Getting this error Everywhere I specified a custom serializer using @Serializable(with = SomeSerializer::class)
    rnett

    rnett

    1 year ago
    What does
    MutableStateSerializer
    look like? I assume it extends
    KSerializer
    ?
    w

    Waqas Tahir

    1 year ago
    class MutableStateSerializer<T>(private val dataSerializer: KSerializer<T>) : KSerializer<MutableState<T>> {
    override val descriptor: SerialDescriptor = dataSerializer.descriptor
    
    override fun serialize(encoder: Encoder, value: MutableState<T>) =
        dataSerializer.serialize(encoder, value.value)
    
    override fun deserialize(decoder: Decoder): MutableState<T> =
        mutableStateOf(dataSerializer.deserialize(decoder))
    
    }
    @Serializable(with = MutableStateSerializer::class)
    var items = mutableStateOf(listOf<ListItem>())
    rnett

    rnett

    1 year ago
    Are
    @Serializable
    annotations supported on local properties (assuming it's not in a class)? I think you want to put it on the type. Other than that it looks good
    w

    Waqas Tahir

    1 year ago
    var items is inside a class and the annotation is above it !
    Dominaezzz

    Dominaezzz

    1 year ago
    Looks like a bug, make an issue.
    Jason Ankers

    Jason Ankers

    1 year ago
    @Waqas Tahir did you end up making an issue for this? We are facing the same problem
    w

    Waqas Tahir

    1 year ago
    Yes made an issue