ursus
05/13/2026, 10:01 PMNav3 or in compose in general, aren't you nervous by the non comp time safety, with all these composition locals, and navigating to a unregistered naventry, or not having keys as serializable, all these are runtime crashes, or worse silent non behaviors if decorators are not installed
Is this the cost of the flexibility?
Is linting then way to make this safer? Has anyone maybe seen lint/detekt rules for Nav3?Kirill Grouchnikov
05/13/2026, 10:17 PMursus
05/13/2026, 10:24 PMursus
05/13/2026, 10:24 PMursus
05/13/2026, 10:30 PMKamilH
05/14/2026, 10:58 AMinternal in some kind of low-level module. For example, you can expose a “nav entry factory” function whose lambda will allow you to subscribe to some kind of Result and keep the implementation internal. Same for the “generic components”. Let’s say you want to have AsyncImage composable. This should get ImageLoader you can accept it in your root composable, propagate it via CompositionLocal and consume in the AsyncImage composable. Then, in your app you just use AsyncImage without the need to read ImageLoader again.ursus
05/14/2026, 1:40 PMprovides it, what happens?KamilH
05/15/2026, 9:45 AMursus
05/15/2026, 9:47 AMStylianos Gakis
05/15/2026, 10:46 AMKamilH
05/15/2026, 10:54 AMursus
05/15/2026, 11:13 AMimage loader for coil etc
If upstream fails to configure, you get a runtime crash.
And I'm wondering if this can be caught ahead of time somehow, other than having a 100% coverage of real app integration tests (not feasible)ursus
05/15/2026, 11:15 AM@Composable
fun App(
modifier: Modifier,
appState: AppState,
) {
AppTheme {
Surface {
// Root LookaheadScope used to anchor all shared element transitions
SharedTransitionLayout(
modifier = modifier.fillMaxSize()
) {
// You may opt to hold a reference to the SharedElementTransitionScope
appState.sharedElementTransitionScope = this@SharedTransitionLayout
CompositionLocalProvider(
LocalAppState provides appState,
) {
// The rest of your app's UI goes here, things like the `NavHost`
// and so on.
...
}
}
}
}
}
internal val LocalAppState = staticCompositionLocalOf<AppState> {
throw IllegalStateException("CompositionLocal LocalAppState not present") <----------
}Stylianos Gakis
05/15/2026, 11:22 AMursus
05/15/2026, 11:43 AMStylianos Gakis
05/15/2026, 12:29 PMursus
05/15/2026, 12:46 PMStylianos Gakis
05/15/2026, 8:50 PM