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

Add onCreate and onDestroy in Lifecycle? #173

Closed
GazimSoliev opened this issue Jul 5, 2023 · 4 comments · Fixed by #230
Closed

Add onCreate and onDestroy in Lifecycle? #173

GazimSoliev opened this issue Jul 5, 2023 · 4 comments · Fixed by #230

Comments

@GazimSoliev
Copy link

Add onCreate and onDestroy in Lifecycle? I wanna cancel my scope in VM when I exactly will know that Screen is destroyed and don't used

@Syer10
Copy link
Contributor

Syer10 commented Jul 5, 2023

Lifecycle already has onDispose, which is the equivalent to onDestroy, and you can make your own lifecycle that has a equivalent to onCreate like we already do in the AndroidLifecycle

@GazimSoliev
Copy link
Author

In testing I found out that onDispose equals onStop, but not onDestroy

@Syer10
Copy link
Contributor

Syer10 commented Jul 30, 2023

onDispose happens when the screen leaves the backstack, making it not recoverable. That is equivalent to onDestroy in the android lifecycle.

@DevSrSouza
Copy link
Collaborator

onCreate I don't think is really needed, a LaunchedEffect(Unit) would be close to what you are looking for.
as @Syer10 said, the onDestroy will be called when the Screen leaves the stack, this is the currently behaviors.

What we don't have yet and will be fixed by #230 is onPause, onResume, onStart, onStop events on LocaLifecycleOwner from Voyager.

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

Successfully merging a pull request may close this issue.

3 participants