Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle Events Not Triggered During Screen Navigation #469

Open
singla-harshul opened this issue Aug 8, 2024 · 4 comments
Open

Lifecycle Events Not Triggered During Screen Navigation #469

singla-harshul opened this issue Aug 8, 2024 · 4 comments

Comments

@singla-harshul
Copy link

While navigating from one screen to another, the onPause and onStop lifecycle events of the previous screen are not being called.

@akardas16
Copy link

While navigating from one screen to another, the onPause and onStop lifecycle events of the previous screen are not being called.

yes, I can also repeat it.

@skymansandy
Copy link

Facing same issue as well.
@adrielcafe @DevNatan Is there any fix for this issue? I'm seeing this was closed as one of the fix PR had got merged: #42

We are still facing the issue in 1.1.0-beta2

@AshuTyagi16
Copy link

I’m also facing the same issue.

Is there any fix for this ?

@skymansandy
Copy link

I'm using this way to listen to lifecycle event.

val lifecycleOwner = LocalLifecycleOwner.current

        DisposableEffect(lifecycleOwner) {
            val observer = LifecycleEventObserver { _, event ->
                // Handle event
            }

            lifecycleOwner.lifecycle.addObserver(observer)
            onDispose {
                lifecycleOwner.lifecycle.removeObserver(observer)
            }
        }

I guess the issue here is with lifecycle observer being removed in onDispose as Screen content is disposed on navigating to new page.

onPause/onStop events are triggered for that screen, but consuming it this way is not possible. What would be the right way in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants