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

[#310] Ensure NavTarget and State are parcelable #311

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

LachlanMcKee
Copy link
Collaborator

@LachlanMcKee LachlanMcKee commented Jan 2, 2023

Description

Fixes #310

Check list

  • I have updated CHANGELOG.md if required.
  • I have updated documentation if required.

@LachlanMcKee LachlanMcKee force-pushed the issue-310-ensure-navtarget-and-state-parcelable branch from e2a15d0 to 42297c6 Compare January 2, 2023 19:54
@@ -15,14 +17,20 @@ class IndexedBackStack<NavTarget : Any>(
savedStateMap = savedState
) {

sealed interface State {
sealed interface State : Parcelable {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug introduced due to a lack of compile-time contracts

@LachlanMcKee LachlanMcKee added bug Something isn't working api-breaking labels Jan 2, 2023
@LachlanMcKee LachlanMcKee force-pushed the issue-310-ensure-navtarget-and-state-parcelable branch from 42297c6 to 9806dbe Compare January 2, 2023 20:31
@LachlanMcKee LachlanMcKee marked this pull request as ready for review January 2, 2023 21:13
@LachlanMcKee
Copy link
Collaborator Author

LachlanMcKee commented Jan 2, 2023

This is definitely a breaking change. We can likely fix the problems (samples that do not use Parcelable) in a different PR, but I think it's worthwhile adding this to avoid issues in the future

@LachlanMcKee
Copy link
Collaborator Author

LachlanMcKee commented Jan 3, 2023

If we don't want to go down this path (I don't see why we shouldn't, other than the fact that we have to make the enums parcelable), we MAY be able to solve this with a detekt rule (though that would mean that the library may not work as advertised if developers don't use detekt)

@CherryPerry
Copy link
Collaborator

CherryPerry commented Jan 3, 2023

The original intention was to allow different types like primitives and serialisables.

We can potentially introduce runtime checks class.java.isPrimitive || class.java.implementsParcelableOrSerializable as an alternative which we can perform in the constructor of NavElement.

Not against your approach.

@LachlanMcKee
Copy link
Collaborator Author

@CherryPerry that could be a good alternative as well. Let's discuss tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-breaking bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavKey navTarget parcelable is not enforced
2 participants