Dario Pellegrini
09/03/2020, 7:27 AMwasyl
09/03/2020, 8:01 AMI change an attribute of a list’s element and re assign the changed listDo the items in the list implement
equals
taking that changed attribute into account?Dario Pellegrini
09/03/2020, 8:47 AMdata class SelectionWrapper<T: Any>(val value: T, var selected: Boolean)
wasyl
09/03/2020, 9:05 AMval list = listOf(selectionWrappers)
mutableStateFlow.value = list
list[0].selected = true
mutableStateFlow.value = list
and the new list is not emitted?Dario Pellegrini
09/03/2020, 3:20 PMval 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)