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 Effect Once API #425

Merged
merged 1 commit into from
May 21, 2024
Merged

Lifecycle Effect Once API #425

merged 1 commit into from
May 21, 2024

Conversation

DevSrSouza
Copy link
Collaborator

This adds to possibility to run a sync block of code, only on the first time the screen appears.

Usage:

LifecycleEffectOnce {
   myScreenModel.initSomething()
}

@DevSrSouza DevSrSouza merged commit ae1f915 into main May 21, 2024
1 check passed
@DevSrSouza DevSrSouza deleted the effect-once branch May 21, 2024 11:34
@@ -16,6 +23,23 @@ public fun Screen.LifecycleEffect(
}
}

@ExperimentalVoyagerApi
@Composable
public fun Screen.LifecycleEffectOnce(onFirstAppear: () -> Unit) {
Copy link
Contributor

@shpasha shpasha May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HelloI think it would be useful to have onDisappear callback here that is called when the screen disappears from the stack

vickyleu pushed a commit to vickyleu/voyager that referenced this pull request May 28, 2024
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 this pull request may close these issues.

2 participants