Berkeli Alashov
07/04/2022, 1:15 AMinterface ColorSpec {
@Composable
operator fun invoke(): Color
companion object {
fun fromColor(lightVariant: Color, darkVariant: Color): ColorSpec = object : ColorSpec {
@Composable
override fun invoke(): Color = if (Theme.isDarkTheme) darkVariant else lightVariant
}
}
}
itnoles
07/04/2022, 2:01 AMBerkeli Alashov
07/04/2022, 2:09 AMAdam Powell
07/04/2022, 2:48 PM@Stable
is probably more semantically correct but the way you've set things up here it won't help you much since you're not defining equals
for the objects returned from your utility. Different but equivalent objects can't skip recomposition if you don't implement equalsBerkeli Alashov
07/05/2022, 3:08 AMdata class
that implements ColorSpec, then I still should use @Stable
?Adam Powell
07/05/2022, 3:10 AMBerkeli Alashov
07/05/2022, 3:11 AMAdam Powell
07/05/2022, 3:12 AMBerkeli Alashov
07/05/2022, 3:14 AMdata
classes will improve skipping behavior?Adam Powell
07/05/2022, 3:18 AMAdam Powell
07/05/2022, 3:18 AMColor
or something else that's known stableAdam Powell
07/05/2022, 3:21 AM@Immutable
and @Stable
in exactly the same way for skipping behaviorBerkeli Alashov
07/05/2022, 3:27 AMAdam Powell
07/05/2022, 3:28 AM