ComposableLifecycleEventObserver

fun ComposableLifecycleEventObserver(observer: ComposableLifecycleObserver, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current)

A Composable function that observes lifecycle events and invokes the corresponding methods on the provided ComposableLifecycleObserver.

Automatically tracks updates to observer to ensure callbacks always execute on the current instance.

Parameters

observer

An instance of ComposableLifecycleObserver that receives lifecycle event callbacks.

lifecycleOwner

The LifecycleOwner to observe. Defaults to LocalLifecycleOwner.current.


fun ComposableLifecycleEventObserver(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, onCreate: (LifecycleOwner) -> Unit? = null, onStart: (LifecycleOwner) -> Unit? = null, onResume: (LifecycleOwner) -> Unit? = null, onPause: (LifecycleOwner) -> Unit? = null, onStop: (LifecycleOwner) -> Unit? = null, onDestroy: (LifecycleOwner) -> Unit? = null, onAny: (LifecycleOwner, Lifecycle.Event) -> Unit? = null)

Convenience Composable function to observe specific lifecycle events via individual callbacks.

Example usage:

ComposableLifecycleEventObserver(
onResume = { /* React to resume */},
onPause = { /* React to pause */},
)