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

knthmn

03/02/2021, 4:38 AM
In https://developer.android.com/jetpack/compose/interop#case-study-broadcastreceivers, the example shows tying a broadcast receiver to the lifecycle of a composable. However (if I understand it correctly), a composable follows the lifecycle of
onCreate
and
onDestroy
(and as long as it is in scope). Is there something I can do to tie it to
onStart
and
onStop
?
i

Ian Lake

03/02/2021, 6:43 AM
What is your use case?
k

knthmn

03/02/2021, 7:52 AM
If I understand the best practices correctly, I should tie the subscription lifecycle to
onStart
and
onStop
if I do not need to value when my UI is not in foreground (e.g.
MediaBrower
client (docs), bound service (docs)). Obviously I can handle it in my activity, but is there a way to do it in a composable?
3 Views