Corbind logo
Follow Star

To add androidx activity bindings, import corbind-activity module:

dependencies {
    implementation("ru.ldralighieri.corbind:corbind-activity:1.11.0")
}

List of extensions

Component Extension Description
OnBackPressedDispatcher backPresses Called when OnBackPressedDispatcher.onBackPressed triggered. OnBackPressed events only
  backProgressed Called when OnBackPressedDispatcher.dispatchOnBackProgressed triggered. OnBackProgressed event only
  backEvents Called when any callback event triggered. All events

Simple examples

onBackPressedDispatcher.backEvents(lifecycleOwner = this)
    .onEach { event ->
        when (event) {
            is OnBackPressed -> { /* handle back pressed event */ }
            is OnBackCanceled -> { /* handle back cancel event */ }
            is OnBackStarted -> { /* handle back started event */ }
            is OnBackProgressed -> { /* handle back progressed event */ }
        }
    }
        .flowWithLifecycle(lifecycle)
        .launchIn(lifecycleScope) // lifecycle-runtime-ktx

More examples in source code