I am using data class as immutable single state being emitted from view model. I print the entire state object when it is emitting, Is there a way to find which property is last updated ?
Copy code
data class SomeState(
val property1: String,
val property2: String
) {
override fun toString(): String {
return "property XX updated"
}
}
j
Joffrey
01/26/2022, 12:26 PM
The class is immutable, so no property is ever updated in this instance. Do you mean that you
copy()
instances of your state by changing only one of the properties, and you want to know in the new state which one was different from the previous state? This would require manual implementation
a
Arun Joseph
01/26/2022, 12:28 PM
Yes I do copy() by changing one property and want to know which was updated. Can I do something overriding copy() method ?
j
Joffrey
01/26/2022, 12:34 PM
I think you should rather write your own methods to change each property, but overriding copy is probably possible too. I never tried to do it