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

Fixed Serialization Issue #9 #11

Merged
merged 7 commits into from
Jul 12, 2023
Merged

Fixed Serialization Issue #9 #11

merged 7 commits into from
Jul 12, 2023

Conversation

chRyNaN
Copy link
Owner

@chRyNaN chRyNaN commented Jul 12, 2023

This PR fixes Issue #9

Changes

  • Exposed the kotlinx.serialization and com.chrynan.parcelable dependencies so that users of the library will not have to manually include those dependencies as they are now transitive
  • Fixed incorrect use of the default Parcelable object instead of the parcelable parameter value in the rememberSavableNavigator functions
  • Manually implemented a KSerializer for Navigator
  • Manually implemented serializers for NavigationEvent s and NavigationEvent.Forward sealed classes

Issue Description

Issue #9 was occurring because of the way kotlinx.serialization handles sealed class polymorphic serialization with generic types. The generated serializer for sealed classes with generic types, apparently requires manually registering every type that will be used with that class. This is not very flexible, so to fix this, I created a NavigationEvent.Snapshot class that was not serializable and contained all the values every NavigationEvent could have. Then I implemented custom serializers for NavigationEvent and its subclass NavigationEvent.Forward (which too is a sealed class) and delegated to the NavigationEvent.Snapshot generated serializer, converting that to and from the appropriate types. This seemed to solve the issue.

@chRyNaN chRyNaN merged commit 5fb6d0e into develop Jul 12, 2023
1 check passed
@chRyNaN chRyNaN deleted the ck/serialization branch July 12, 2023 16:25
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.

crash on rememberSavableNavigator
1 participant