'When should I use @Immutable in compose?
Where should I place Immutable annotation to enable composition optimizations ? 1, 2 or/and 3 and why ?
It confused me that standart VisualTransformation interface for TextField has this annotation, but PasswordVisualTransformation doesn't and @Immutable is not inherited
// 1 - @Immutable
sealed class State(val option1: String) {
// 2 - @Immutable
object One : State("")
// 3 - @Immutable
data class Two(val option2: String) : State("")
}
@Composable
fun Screen(state: State) { }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
