Mijael Viricochea
09/09/2020, 2:21 PM@ExperimentalCoroutinesApi
fun deleteSelected() {
val value = dataPoints.value
value.removeAll { it.selected }
dataPoints.value = ArrayList(value)
}
bezrukov
09/09/2020, 2:25 PMbezrukov
09/09/2020, 2:26 PMdataPoints.value = dataPoints.value.filter { !it.selected }
bezrukov
09/09/2020, 2:27 PMval value = ArrayList(dataPoints.value)
value.removeAll { it.selected }
dataPoints.value = value
Mijael Viricochea
09/09/2020, 2:36 PMMijael Viricochea
09/09/2020, 11:25 PMfun sweepAll() {
val value = mutableListOf<DataPoint>()
value.addAll(dataPoints.value)
value.forEach {
it.x = null
it.y = null
}
dataPoints.value = value
}
I have this function and the value again is not changing, can you please tell me why is that?bezrukov
09/10/2020, 7:51 AMbezrukov
09/10/2020, 7:51 AMdataPoints.value = value
. But you made it.x = null
on original datapoint, so it was changed in both listsbezrukov
09/10/2020, 8:01 AMdata class Wrapper(val version: Int, data: List<DataPoints>)
and on each update you need to copy this wrapper with increased version
.
but it's hacky and better to use immutable data.