aoriani
10/26/2023, 11:04 PMval _composables_ = _MutableStateFlow_<List<@Composable () -> Unit>>(_emptyList_())
?Pablichjenkov
10/26/2023, 11:07 PMjw
10/26/2023, 11:15 PM@Composable { for (lambda in lambdas) lambda()
and encapsulate the state list. Compose will recompose when it changes, and your consumers only get a single composable lambda to put wherever. No collection or iteration at the consumption site, just a single invocationaoriani
10/26/2023, 11:25 PMjw
10/26/2023, 11:27 PMaoriani
10/26/2023, 11:29 PMPablichjenkov
10/27/2023, 1:26 AMinterface Component {
@Composable
fun View()
}
Or without polymorphism, having a huge Composable mapper function that basically does this:
@Composable
fun genericRenderer(
serverComponentMetadata ComponentMetadata
) {
when(serverComponentMetadata) {
Component1 -> Component1Composable(
serverComponentMetadata
)
Component2 -> Component2Composable(
serverComponentMetadata
)
...
}
}
But this map tends to grow huge and also calling this function pretty much everywhere sounds repetitive. Haven't found any other alternatives.