<https://developer.android.com/topic/architecture/...
# compose
r
https://developer.android.com/topic/architecture/ui-layer/events Here in this doc, I see two ways on the same page for handling login event. I mean I understand that the second one considers lifecycle but still, it is confusing when I immediately see two options that make me think about when to use what, and which one is better. Option 1:
Copy code
val currentOnUserLogIn by rememberUpdatedState(onUserLogIn)

    // Whenever the uiState changes, check if the user is logged in.
    LaunchedEffect(viewModel.uiState)  {
        if (viewModel.uiState.isUserLoggedIn) {
            currentOnUserLogIn()
        }
    }
Option 2:
Copy code
val lifecycle = LocalLifecycleOwner.current.lifecycle
    val currentOnUserLogIn by rememberUpdatedState(onUserLogIn)
    LaunchedEffect(viewModel, lifecycle)  {
        // Whenever the uiState changes, check if the user is logged in and
        // call the `onUserLogin` event when `lifecycle` is at least STARTED
        snapshotFlow { viewModel.uiState }
            .filter { it.isUserLoggedIn }
            .flowWithLifecycle(lifecycle)
            .collect {
                currentOnUserLogIn()
            }
    }