https://kotlinlang.org logo
#compose
Title
# compose
n

Napa Ram

09/03/2021, 5:48 AM
is there a way to handle life cycle as we are not using fragment and only one activity is there is project, i need inform view model 1. when compose screen created 2. when app go in background 3. when moving from one screen to another and when we are coming back to same screen 4. basically all lifecycle event
j

Johan Reitan

09/03/2021, 6:44 AM
👀 1
a

Alex

09/03/2021, 6:44 AM
Just do it in the activity and pass the values to the viewmodel, which then in turn can expose StateFlows to inform your composition
n

Napa Ram

09/03/2021, 10:09 AM
in my project there are around 15-20 module it will be difficult to handle everything in one activity a
is compose not giving anything regarding lifecycle
j

Johan Reitan

09/03/2021, 10:10 AM
Yes, you have the
repeatOnLifecycle
that’s explained in the linked post above. They even have an example with Compose at the end
👍 2
i

Ian Lake

09/03/2021, 2:52 PM
m

Michael Paus

09/04/2021, 9:50 AM
I am wondering how the lifecycle handling concepts explained in the article will map to Compose Desktop where you are facing the same problem but don’t have all these Android specific APIs available. Or am I missing something here?
2 Views