The Developer Preview for Android 11 is now available; test it out and share your feedback.

CompositionLifecycleObserver

interface CompositionLifecycleObserver
androidx.compose.CompositionLifecycleObserver

Instances of classes implementing this interface are notified when they are initially used during composition and when they are no longer being used.

Summary

Public methods

abstract Unit

Called when the instance is used in composition.

abstract Unit

Called when the instance is no longer used in the composition.

Inherited extension functions

From androidx.compose
operator T

IMPORTANT: This global operator is TEMPORARY, and should be removed whenever an answer for contextual composers is reached.

Public methods

onEnter

abstract fun onEnter(): Unit

Called when the instance is used in composition.

onLeave

abstract fun onLeave(): Unit

Called when the instance is no longer used in the composition.