`collectAsStateWithLifecycle()` is not collecting ...
# compose-android
i
collectAsStateWithLifecycle()
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......
i
That is the Known Issue mentioned in the release notes, already fixed for the next version: https://developer.android.com/jetpack/androidx/releases/navigation3#1.0.0-alpha08
❤️ 1
i
Copy code
val 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
Copy code
@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 today
Created Issue in IssueTracker (Navigation 3) https://issuetracker.google.com/issues/443621713
i
...which is a duplicate of that Known Issue
👍 1
i
Still an issue??? (Not Fixed?) If No, then fine, If Yes, Still I facing the above issue in alpha08 itself........
t
The release notes say that the version after alpha08 is going to fix it, it's not released yet
i
Oh, I see, Thanking all for clarifications....
g
This issue exists also in Compose Multiplatform
1.10.0-alpha01
@Irsath Kareem Thanks for the fix! 😊