-
Notifications
You must be signed in to change notification settings - Fork 90
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
Closed
luca992
wants to merge
18
commits into
dbaroncelli:main
from
luca992:polymorphic-json-serialization-screen-params
Closed
Polymorphic Serialization of ScreenParams. #26
luca992
wants to merge
18
commits into
dbaroncelli:main
from
luca992:polymorphic-json-serialization-screen-params
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
luca992
force-pushed
the
polymorphic-json-serialization-screen-params
branch
2 times, most recently
from
September 14, 2023 04:57
5fdd9c0
to
5016d0a
Compare
luca992
force-pushed
the
polymorphic-json-serialization-screen-params
branch
from
September 14, 2023 05:13
5016d0a
to
2a8e851
Compare
I'll recreate this pr this after you look at #28 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This builds upon my other pr #25.
It switches to using polymorphic serialization of ScreenParams with
kotlinx.serialization
.Note: I moved all
ScreenParams
implementations ineu.baroncelli.dkmpsample.shared.viewmodel.screens.ScreenParams
instead of inside a screen'seu.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.