Chuck Stein
08/06/2021, 7:11 PMJavier
08/06/2021, 8:50 PMIan Lake
08/06/2021, 10:21 PMChuck Stein
08/08/2021, 10:52 PMComposableDestination
), with properties that we can override like
route: String
, arguments: List<NamedNavArgument>
, and deepLinks: List<NavDeepLink>
. Then at compile time any `object`s inheriting from it (which could be identified with an annotation if necessary) will get the following generated code: a data class representing a set of arguments that can be passed into this destination (if it takes any), a function that returns an instance of this data class from a NavBackStackEntry
, and a function for navigating to the destination, which takes in the proper arguments, strongly typed, and under the hood uses them to construct a String representing the route to navigate to. Also, if we have this ComposableDestination
type, then we could add the following overload for `NavGraphBuilder.composable`:
fun NavGraphBuilder.composable(destination: ComposableDestination, content: @Composable (NavBackStackEntry) -> Unit) {
composable(destination.route, destination.arguments, destination.deepLinks, content)
}
Chuck Stein
08/08/2021, 10:53 PMChuck Stein
08/08/2021, 10:53 PMChuck Stein
08/08/2021, 11:00 PMComposableDestination
there could also be a NavGraphDestination
type, with the properties route: String
and startDestination: String
, along with corresponding overloads for NavGraphBuilder.navigation
and the NavHost
composable to take in a NavGraphDestination
instead of a route
and startDestination
directly. Then we can generate a function for navigating to this nav graph, which uses the route
property under the hood.Ian Lake
08/08/2021, 11:03 PMChuck Stein
08/08/2021, 11:10 PMChuck Stein
08/08/2021, 11:18 PMChuck Stein
08/11/2021, 11:55 PMSafe Args is strongly recommended for navigating and passing data, because it ensures type-safety.What is it about the Compose paradigm that makes type-safety no longer as important, if it was previously strongly recommended?
Ian Lake
08/11/2021, 11:59 PMIan Lake
08/12/2021, 12:00 AMIan Lake
08/12/2021, 12:03 AMIan Lake
08/12/2021, 12:07 AMChuck Stein
08/12/2021, 12:34 AMIan Lake
08/12/2021, 3:45 AM