-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
How to implement navigation type safety in NiaNavHost? #1613
Comments
In typeSafeNavigation (version 2.8.0) you can pass a route: T as argument, this class should be Serializable , you can pass item in this class like this:
Then you should create an custom type for this type like this :
Then you should use typeMap as argument for screenB like this:
And now you can pass data from another screen like this :
In your way, class ItemUi must be annotated with Serialization. Also, if this class contains a custom variable, it must also be Serialized, then you can use :
For your issue: Should add new composable to NiaNavHost, then from foryouScreen when onTopicCall , do a work like this
You should have this
|
According to this post, starting with version 2.8.0-alpha08 of Navigation objects can be used in navigation.
I'm trying to implement it, because I need to pass instances of an object called
ItemUI
instead of passing a simple value, but it doesn't work for me.This is what I've been trying:
ForYouNavigation
NiaNavHost
navigateToTodays
At this line
navigate(topicId, navOptions)
I have this error:
Type mismatch: inferred type is ItemUI? but TypeVariable(T) was expected
The text was updated successfully, but these errors were encountered: