Is `State` considered `Stable` because any change...
# compose
y
Is
State
considered
Stable
because any changes will cause a recomposition? (If not then why?)
y
1) The result of [equals] will always return the same result for the same two instances.
Isn't this line ambiguous though? Since
value
is mutable in
MutableState
, if you change the value between two equals, wouldn't the result differ?
Copy code
var value1 by mutableStateOf(0)
var value2 by mutableStateOf(0)

value1 == value2 // true
value1 = 1
value1 == value2 // false
Feels like the description is not clear enough, or maybe I'm missing something.
"for the same two instances"
should be more precise maybe
a
this is
equals
on the
@Stable
object instances, not on
.value
so as per the example above,
Copy code
var state1 = mutableStateOf(0)
var state2 = mutableStateOf(0)

state1 == state2 // false
state1.value = 1
state1 == state2 // false
the property delegation hides the real objects that must be
.equals
for the stability contract
y
Ooooh, I thought
State
.equals
implementation was comparing values. Ok that makes sense now. Thanks!
👍 1