backPresses

Create a Flow of on back pressed events on the OnBackPressedDispatcher instance.

Parameters

owner

the LifecycleOwner which controls when the callback should be invoked.

Note: Created flow keeps a strong reference to the OnBackPressedDispatcher instance until the coroutine that launched the flow collector is cancelled.

Example of usage:

onBackPressedDispatcher.backPresses(lifecycleOwner)
.onEach {
// handle back pressed
}
.launchIn(uiScope)