# compose

Zach Klippenstein (he/him) [MOD]

07/23/2020, 8:24 PM
Does a
that enters a composition by being captured by a composable lambda get its callbacks invoked? E.g.
Copy code
class MyActivity : AppCompatActivity() {
  private val myObserver: CompositionLifecycleObserver = object : …

  override fun onCreate() {
    setContent { MyApp(myObserver) }
AFAIK the only way an observer can be “registered” is by being returned from
remember {}
🤔 1

Leland Richardson [G]

07/23/2020, 9:11 PM
Unfortunately it’s a little bit harder to define than that. If you are relying on it, use remember
it can also happen by being passed as a parameter
👍 1

Adam Powell

07/23/2020, 9:29 PM
also useful to know is that if an object that implements CLO is remembered in several places, it won't leave the composition until it leaves everywhere, including all of the cases of remembered parameters for restarting composable function calls.
if you want to know for sure if a specific composable function call has left the composition by way of a CompositionLifecycleObserver, don't let the reference to the actual CLO object escape to user code.