val colors = MaterialColors(primary = myTheme.primaryColor) MaterialTheme(colors) {
}
If 'MaterialTheme' internally uses an ambient, changing myTheme.primaryColor will synchronously cause the ambient value to change and update its consumers. However, if MaterialTheme actually has a @Model class that gets mutated, then this will result in another recomposition for anything consuming that @Model class.
One proposed solution could be knowing that the @Model class is mutated above the scope where it is being consumed, so in the same recomposition pass we can invalidate and recompose anything consuming it.
Description
@Model
class MyTheme(var primaryColor: Color)
...
val colors = MaterialColors(primary = myTheme.primaryColor)
MaterialTheme(colors) {
}
If 'MaterialTheme' internally uses an ambient, changing myTheme.primaryColor will synchronously cause the ambient value to change and update its consumers. However, if MaterialTheme actually has a @Model class that gets mutated, then this will result in another recomposition for anything consuming that @Model class.
One proposed solution could be knowing that the @Model class is mutated above the scope where it is being consumed, so in the same recomposition pass we can invalidate and recompose anything consuming it.