Irsath Kareem
09/08/2025, 10:58 AMcollectAsStateWithLifecycle()
is not collecting when we use Navigation3 as the Composable is receiving only Lifecycle.state.CREATED not Lifecycle.State.STARTED. But the collect**cycle()
needs STARTED state.
If we manually change minActiveState = CREATED, Then its fine, But the default is not working.......
Navigation3 Version: 1.0.0-alpha08
Lifecycle Navigation3: 2.10.0-alpha03
Runtime, UI, Viewmodel-nav3 libraries
Also included ViewModelStoreNavEntryDecorator, SavedStateNavEntryDecorator... as recommended.
If I fallback to the Navigation-Compose (Legacy), It is working fine......Ian Lake
09/08/2025, 1:45 PMIrsath Kareem
09/08/2025, 2:22 PMval tickFlow = flow {
repeat(300) {
emit(it)
delay(1000)
}
}
@Composable
fun RoutesScreen() {
val tick by tickFlow.collectAsStateWithLifecycle(initialValue = 1000)
Box(modifier = Modifier.fillMaxSize(), Alignment.Center) {
Text("$tick", fontSize = 30.sp, fontWeight = FontWeight.ExtraBold)
}
}
Here the screen is showing always 1000, means tickFlow
not started
Additional Context
@Composable
fun Test2App() {
val backstack = rememberNavBackStack(RoutesRoute)
NavDisplay(
backStack = backstack,
entryDecorators = listOf(
rememberSceneSetupNavEntryDecorator(),
rememberSavedStateNavEntryDecorator(),
rememberViewModelStoreNavEntryDecorator(),
),
entryProvider = entryProvider {
entry<RoutesRoute> { RoutesScreen() }
}
)
}
MainActivity {
setContent {
Test2App()
}
}
If I change as collectAsStateWithLifecycle(1000, minActiveState = Lifecycle.State.CREATED)
, then it is working.
I am using Latest Alpha Versions only (as I mentioned in Previous Message) as of todayIrsath Kareem
09/08/2025, 3:31 PMIan Lake
09/08/2025, 3:36 PMIrsath Kareem
09/08/2025, 3:42 PMTgo1014
09/08/2025, 3:44 PMIrsath Kareem
09/08/2025, 3:45 PMgalex
09/12/2025, 7:52 AM1.10.0-alpha01
@Irsath Kareem Thanks for the fix! 😊