doOnDestroy

fun LifecycleOwner.doOnDestroy(onDestroy: (owner: LifecycleOwner) -> Unit): LifecycleObserver

A convenience function that calls onDestroy when the LifecycleOwner is destroyed.

It returns the LifecycleObserver registered internally, allowing callers to unregister it earlier if desired. Otherwise it will automatically be removed upon destroying.


fun Lifecycle.doOnDestroy(onDestroy: (owner: LifecycleOwner) -> Unit): LifecycleObserver

A convenience function that calls onDestroy when the Lifecycle is destroyed.

It returns the LifecycleObserver registered internally, allowing callers to unregister it earlier if desired. Otherwise it will automatically be removed upon destroying.