Skip to content

Commit

Permalink
Update docs with LifecycleEffectOnce onDispose
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSrSouza committed Oct 7, 2024
1 parent 6103d3a commit 6c22413
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

** Experimental API

Inside a `Screen`, you can call `LifecycleEffectOnce` to execute a block of code the first time the Screen appears:
Inside a `Screen`, you can call `LifecycleEffectOnce` to execute a block of code the first time the Screen appears,
and optionally define a `onDispose` callback for when the Screen is leaving/removed from the Stack:

```kotlin
class PostListScreen : Screen {
Expand All @@ -11,6 +12,9 @@ class PostListScreen : Screen {
override fun Content() {
LifecycleEffectOnce {
screenModel.initSomething()
onDispose {
// Do something when the screen is leaving/removed from the Stack
}
}

// ...
Expand Down

0 comments on commit 6c22413

Please sign in to comment.