Zoltan Demant
03/09/2023, 6:10 AMStateFlow
? Id think that the first emission comes through, but if you then edit the class and emit it anew, nothing will come through given how StateFlow compares equals before emitting new items?Albert Chang
03/09/2023, 6:34 AMStateFlow
just calls equals()
to compare the values, and an object always equals itself (unless you override the method and return false, which is wrong anyway).Zoltan Demant
03/09/2023, 6:54 AMdata class Item(
var label: String
)
Albert Chang
03/09/2023, 6:56 AMAlbert Chang
03/09/2023, 6:59 AMitem
variable and the value in the state flow is the same object, so when you change item.label
from outside, the label
of the object inside the state flow is also changed.Zoltan Demant
03/09/2023, 7:01 AMTimo Gruen
03/09/2023, 7:50 AMlabel
inside the Item
object, the equals check should see unequal objects.Albert Chang
03/09/2023, 8:09 AMval item1 = Item(label = "1")
val item2 = item1
item2.label = "2"
println(item1 == item2)
What will it print? You can also run it yourself.Timo Gruen
03/09/2023, 8:22 AMPatrick Steiger
03/10/2023, 8:46 PM