Thread
#compose
    Yann Badoual

    Yann Badoual

    2 years ago
    Is
    State
    considered
    Stable
    because any changes will cause a recomposition? (If not then why?)
    Yann Badoual

    Yann Badoual

    2 years ago
    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?
    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
    Adam Powell

    Adam Powell

    2 years ago
    this is
    equals
    on the
    @Stable
    object instances, not on
    .value
    so as per the example above,
    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
    Yann Badoual

    Yann Badoual

    2 years ago
    Ooooh, I thought
    State
    .equals
    implementation was comparing values. Ok that makes sense now. Thanks!