being recreated on each composable function call here? I can't put this in "remember", because
MyTheme.colors.someColor
is a
Composable
getter:
Copy code
fun MyComposable() {
val colors = PlotColors(
positiveColor = MyTheme.colors.indicatorContentGreen,
negativeColor = MyTheme.colors.indicatorBackgroundRed,
)
}
dimsuz
11/12/2021, 11:15 AM
Oh. I suppose I could do
Copy code
val positiveColor = MyTheme.colors.indicatorContentGreen,
val negativeColor = MyTheme.colors.indicatorContentGreen,
val colors by remember { PlotColors(positiveColor, negativeColor) }
but that would get very verbose in presence of many colors
c
Csaba Kozák
11/12/2021, 11:17 AM
Seems to be an unnecessary optimisation. You end up creating a lot more objects when using compose anyways. Compose will skip recomposition if your input does not change.
d
dimsuz
11/12/2021, 11:18 AM
Thought so too, asked just in case I sometime will need something like this in a performance critical path with a lot of updates.