robnik
04/29/2021, 3:00 PMrobnik
04/29/2021, 3:00 PMclass MyViewModel: ViewModel() {
private val repo = Repository()
var vehicleID: String by mutableStateOf("")
set() { // Compiler does not allow this
repo.saveVehicleID(vehicleID)
cachedInfo = null
}
}
Adam Powell
04/29/2021, 3:21 PMprivate var _vehicleId by mutableStateOf("")
and keep a custom getter and setter for the public property that read and write it. You don't have to do anything special to keep the observability working.