Hey my people, if anyone is interested, why isn’t ...
# compose
c
Hey my people, if anyone is interested, why isn’t there a more sure way to use this function:
Copy code
public fun NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    content: @Composable (NavBackStackEntry) -> Unit
) {
I was recently thinking about a way to make it more sure that all the variables would be more involved in a way that we could assure correct navigation. This came from a colleagues question about “if the route was different than the” called navigation path:
Copy code
const val toTest = "$TEST/{$TEST_VALUE}"
Copy code
fun test(testValue: Int) {
    navController.navigate("$TEST/$testValue")
}
Because of this I was thinking if we could have an object that would make this a more sure process. Does it make sense? Is my process incorrect? Accepting suggestions 🙂 My plan now would be to overwrite this NavGraphBuilder.composable function in a way that it would receive this object and that I could use this object instead of this loose variables 🙂
i
You can certainly write whatever layers of wrappers you feel are necessary. As per the guide (https://developer.android.com/jetpack/compose/navigation#testing), you should already be building type safe lambdas that you pass down to your individual screen, keeping all of your route information all in one place: where you define your graph
🙌🏽 1