Wrote a little post for rendering decompose when u...
# decompose
a
Wrote a little post for rendering decompose when using the compose extensions to avoid large when blocks when using the
Children
composable. Hope this helps someone and open to feedback! https://plusmobileapps.com/blog/2026/06/15/letting-a-decompose-bloc-render-itself/
So turn this:
Copy code
Children(stack = bloc.routerState) { child ->
    when (val instance = child.instance) {
        is Child.CookMode -> CookModeScreen(instance.bloc)
        is Child.Detail   -> RecipeDetailScreen(instance.bloc)
        is Child.Edit     -> EditRecipeScreen(instance.bloc)
        // ...one arm per screen
    }
}
Into this:
Copy code
Children(stack = bloc.routerState) { child ->
    child.instance.bloc.Content()
}
By adding a simple interface:
Copy code
interface ComposeScreen {
    @Composable fun Content(modifier: Modifier)
}
Then having each component implement that interface and be the type of the router.
a
Thanks for sharing!
Glad you are still using it!
♥️ 1