https://kotlinlang.org logo
#kobweb
Title
# kobweb
f

Funyinoluwa Kashimawo

10/28/2023, 8:24 PM
Hi @David Herman, I noticed that for pages that I load data in the
LaunchedEffect
after I navigate to another page then navigate back. The launched effect is triggered again. Please confirm if this is the expected behavior or suggest how to load the data once.
d

David Herman

10/28/2023, 8:30 PM
Yes, for sure. This would be like having a LaunchedEffect in an screen in Android. I imagine it would fire again when you exited and reentered the screen?
You may want to use
LocalStorage
or
SessionStorage
if you want something to survive across pages
f

Funyinoluwa Kashimawo

10/28/2023, 10:51 PM
Yeah it is the same behavior in compose android. I'll look into session storage, thanks.
d

David Herman

10/28/2023, 10:55 PM
Sounds good. LaunchedEffect will fire the first time any composable goes from not being called to being called. You can look at your method annotated with
@App
also btw. Any launched effect in there should only be called once (or if one of its keys change)
f

Funyinoluwa Kashimawo

10/28/2023, 10:56 PM
Oh thanks, I'll check that out too. Thank you very much.
d

David Herman

10/28/2023, 10:57 PM
You're welcome!
3 Views