This question is about strategies when using slot ...
# compose
m
This question is about strategies when using slot API. In this example, in the rare occurrence of
Foo
being a certain type, the composable needs to handle showing a dialog. Is this way acceptable, or should the
showDialog
mutable state always be kept outside of the slot composable arg?
Copy code
@Composable
fun Screen(foo: Foo) {
    FooView(
        fooContent = {
            if (foo is RareFoo) {
                var showDialog by rememberSaveable {
                    mutableStateOf(false)
                }
                if (showDialog) {
                    RareDialog(foo) {
                        showDialog = false
                    }
                }
                RareFooView(foo)
            } else {
                NonRareFooView(foo)
            }
        },
        ...
    )
}