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

Allow @kotlinx.serialization.Serializable for Navigation Results #235

Open
cvb941 opened this issue Sep 8, 2022 · 6 comments
Open

Allow @kotlinx.serialization.Serializable for Navigation Results #235

cvb941 opened this issue Sep 8, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@cvb941
Copy link

cvb941 commented Sep 8, 2022

Kotlin's @Serializable types currently work as navigation arguments, but not for navigating back with a result using ResultBackNavigator and ResultRecipient.

Is it possible to add support for @Serializable there as well?

@petrstetka
Copy link
Contributor

Hello @raamcosta, Is there any way I can help implement this? I would like to see a support for this, or rather I need it because without this kotlinx.serializable is not possible to fully use with this library and I don't want to resort to using parcelable or other serializers when the official kotlinx.serializatio is here with us today.

You wrote last this:

kotlin("plugin.serialization")

Hmmm I'd like to avoid this if possible. I don't known yet exactly how.. I'm guessing we can also generate the serializers like we do for navigation on the user's module and have them point to them by passing their instance or something like this.
To be honest, if this is the only way, I'd rather not do it. I don't want to force this dependency on all users of the library. Maybe we could make this a separate dependency, but that also comes with additional overhead for all maintainers...

So do you have an idea how it should work and how to implement it?
From what I've seen in the code for resultRecipients / resultNavigator there is no generating the serializers now as in the case of navigation arguments, is that right?

@LukasAnda
Copy link

LukasAnda commented Jul 20, 2023

@raamcosta any updates on this please? It forces me to not to pass data back as originally intended but only by ID or serialize to String since I removed all Parcelable/serializable imports due to KMM.

Or, is there any way I can help to support this feature?

@ryanholden8
Copy link

+1 for this request. When reading the docs I thought this was already implemented but we get this error:

com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup: Composable Screen, ResultDataModel: Result types must be one of: String, Long, Boolean, Float, Int, Parcelable, Serializable

I guess Serializable here is referring to java.io.Serializable ? I had to dive into the source code to figure that out.. I think Serializable referring to @kotlinx.serialization.Serializable would be a more natural conclusion for most Kotlin projects..

@ryanholden8
Copy link

Ah seems like java.io.Serializable vs @kotlinx.serialization.Serializable is a common mistake: #266 (comment)

@whitescent
Copy link

Any updates on this? @raamcosta

@raamcosta
Copy link
Owner

Hi 👋

No, this is not a priority for v2 at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants