Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Created December 24, 2019 14:21
Show Gist options
  • Save zsoltk/e7183639ef78b609d15151706668d238 to your computer and use it in GitHub Desktop.
Save zsoltk/e7183639ef78b609d15151706668d238 to your computer and use it in GitHub Desktop.
sealed class Routing {
object ChildScreen1 : Routing()
object ChildScreen2 : Routing()
data class ChildScreen3(val foo: Bar) : Routing()
}
@Composable
fun MyParentComposable(defaultRouting: Routing) {
BackHandler(defaultRouting) { backStack ->
// backStack contains elements of Routing
when (val routing = backStack.last()) {
// compose further based on current routing
// manipulate backStack with push/replace/etc. operations to trigger recompose
// use back press on device to pop backstack and trigger recompose
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment