usually in iOS i will do a didSet
but Kotlin does not provide the same, how can I do Such a thing.
`
val dnValues = stringArrayResource(R.array.dn_values_array)
val pnValuesSteel = stringArrayResource(R.array.pn_values_array_full)
val pnValuesGray = stringArrayResource(R.array.pn_values_array_gray_iron)
val pnValuesDuctile = stringArrayResource(R.array.pn_values_array_ductile_iron)
var pnValues = pnValuesGray
val materialValues = stringArrayResource(R.array.materials_array)
val newMaterial: (String) -> Unit = { material ->
when (material) {
materialValues[0] -> {
pnValues = pnValuesGray
}
materialValues[1] -> {
pnValues = pnValuesDuctile
}
materialValues[2] -> {
pnValues = pnValuesSteel
}
}
}`
when I debug the code I see the pnValues change the way I want, but the UI never refresh on the edit.
I have tried the previous comments, because the Values get stuck on the remembered ones and the Custom picker won't work.
what I did was, just removing the pnValuesSteel, Gray, Ductile and set the correct one depending on the material which I retrieve from the chosen one on the picker. setting the pnValuesSteel, Gray, Ductile (values) I have done it in the same scope where it should be assigned. see below
now it works perfectly.
any comments on the solution would be appreciated.