<@UHAJKUSTU> If i start a flow in my RootComponent...
# decompose
v
@Arkadii Ivanov If i start a flow in my RootComponent's coroutine scope and minimize the app, will the flow still run ?
a
Yes it should keep running until the component is destroyed. Unless you are using extensions like
flowWithLifecycle
.
v
When is the component destroyed?
I have a usecase which involves some background data upload, i was thinking of using a foreground service. Could using root component scope, help me get rid of a foreground service?
a
The component is destroyed when it's removed from navigation (e.g. popped from the stack), or configuration change occurs on Android (we use InstanceKeeper to overcome this), or the process is terminated (you might not receive onDestroy in this case, though). For background processing, a foreground service or WorkManager should normally be used.
Decompose components are similar to Android fragments in this regard.
v
Its the topmost root component, used as a retained component
In case of theme change or screen rotate, will this component, get recreated?
a
If the component is retained, then it won't be recreated. Though, we can't control the process death if the activity is in background and there is no foreground service etc.
v
I see, thanks a lot. So the coroutine scope will still be active. Its a small video upload process which i want, so this should suffice i guess, creating a foregound service in a kmp shared module is kinda hectic
a
It might work but there is no guarantee of how long the process will be alive. Also there will be new restrictions in Android 15: https://developer.android.com/about/versions/15/behavior-changes-all#background-network-access
Some Android vendors tend to kill background apps aggressively.