Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic Serialization of ScreenParams. #26

Conversation

luca992
Copy link

@luca992 luca992 commented Sep 13, 2023

This builds upon my other pr #25.

It switches to using polymorphic serialization of ScreenParams with kotlinx.serialization.

Note: I moved all ScreenParams implementations in eu.baroncelli.dkmpsample.shared.viewmodel.screens.ScreenParams instead of inside a screen's eu.baroncelli.dkmpsample.shared.viewmodel.screens.screen-name subpackage, because all classes implementing a sealed interface must be in the same package. The reason I used a sealed interface is that it allows the list of ScreenParams subclasses that can be serialized in a polymorphic way to be determined at compile time vs having to explicitly registered them at runtime.

Also this fixes the issue where the app crashes on start if you change variable names inside ScreenParams after relaunching the app. Previously this causes a deserialization error when reading the serialized ScreenParams from local settings. When a deserialization error is encountered this pr will work around the issue by retrying with the default params for screen.

@luca992 luca992 force-pushed the polymorphic-json-serialization-screen-params branch 2 times, most recently from 5fdd9c0 to 5016d0a Compare September 14, 2023 04:57
@luca992 luca992 force-pushed the polymorphic-json-serialization-screen-params branch from 5016d0a to 2a8e851 Compare September 14, 2023 05:13
@luca992
Copy link
Author

luca992 commented Oct 11, 2023

I'll recreate this pr this after you look at #28

@luca992 luca992 closed this Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant