KwikComposableLifeCycle

fun KwikComposableLifeCycle(onResume: () -> Unit = {}, onPause: () -> Unit = {}, onStarted: () -> Unit = {})

Helper component to observe the lifecycle of the current LifecycleOwner and call the provided onResume and onPause callbacks when the lifecycle events occur. This is useful for components that need to perform actions when the Composable is resumed or paused.

Be aware that the onResume callback will be called when the Composable is first created. Also make sure that whatever you do in the onResume and onPause callbacks is idempotent. Otherwise you might perform an expensive operation multiple times. Imagine an API call in the onResume callback, if the Composable is recomposed, which can happen multiple times within a second, the API call will be made again.

Parameters

onResume

Callback to be called when the Composable is resumed.

onPause

Callback to be called when the Composable is paused.