Yes. Probably that’s the problem. I don’t see any ...
# flow
d
Yes. Probably that’s the problem. I don’t see any fast solution for solving this with MutableStateFlow. Probably simply MutableStateFlow is not the correct class to use in this case
w
I change an attribute of a list’s element and re assign the changed list
Do the items in the list implement
equals
taking that changed attribute into account?
d
Those items are instances of data class that if I remember correctly automatically implements equal using its own attributes
Copy code
data class SelectionWrapper<T: Any>(val value: T, var selected: Boolean)
w
And you’re saying you have
Copy code
val list = listOf(selectionWrappers)
mutableStateFlow.value = list
list[0].selected = true
mutableStateFlow.value = list
and the new list is not emitted?
d
Yeah
Wait I send you an example
Copy code
val mutableStateFlow = MutableStateFlow(arrayOf<Person>())
fun start() = CoroutineScope(Dispatchers.Main).launch {
    mutableStateFlow.onEach {
        Log.i("MutableStateFlow", "$it")
    }.launchIn(this)

    mutableStateFlow.value = arrayOf(Person("Dario", "P"))
    delay(1000L)
    val array = mutableStateFlow.value
    array[0].name = "Da"
    mutableStateFlow.value = array
}

data class Person(var name: String, val surname: String)
With more simple class