https://kotlinlang.org logo
v

Vinay Gaba

11/01/2020, 9:36 PM
this is the handler in question
Copy code
@Composable
internal fun BackButtonHandler(onBackPressed: () -> Unit) {
    Providers(
        AmbientBackPressedDispatcher provides LifecycleOwnerAmbient.current as AppCompatActivity
    ) {
        handler {
            onBackPressed()
        }
    }
}
i

Ian Lake

11/01/2020, 9:51 PM
Yeah, you don't want the
LifecycleOwnerAmbient
, you probably want to start with
ContextAmbient
Ideally, Compose just provides a
OnBackPressedDispatcherOwnerAmbient
that does exactly that for you
☝️ 1
1
v

Vinay Gaba

11/01/2020, 9:55 PM
Thanks a lot Ian! Let me give this a shot and see how far I get with it 😄
Is something like
OnBackPressedDispatcherOwnerAmbient
on the roadmap?
i

Ian Lake

11/02/2020, 12:47 AM
I'd be all for it. Do you mind filing an issue against Jetpack -> Compose?
v

Vinay Gaba

11/02/2020, 2:11 AM
Absolutely!
i

Ian Lake

11/02/2020, 3:34 AM
If you could paste a link to it here when you file it, I'll make sure it is routed to the right person
v

Vinay Gaba

11/02/2020, 4:44 AM
i

Ian Lake

05/24/2023, 3:27 PM
No
2 Views