Thread
#compose
    Geert

    Geert

    1 year ago
    I just tried to add a onbackpress dispatcher to a composable function. It works, but should I place it the function, SideEffect, LaunchedEffect, or DisposableEffect? I have to add it since it needs the call popBackStack() multiple times (or popUpTo)
    Albert Chang

    Albert Chang

    1 year ago
    Should be like this:
    DisposableEffect(callback) {
        // Add callback
        onDispose {
            // Remove callback
        }
    }
    i

    Ian Lake

    1 year ago
    You should use the
    BackHandler
    API in Activity Compose 1.0.0-alpha02, which does all this correctly for you: https://developer.android.com/jetpack/androidx/releases/activity#1.3.0-alpha02