I have ```private val _toneMap = MutableStateFlow(...
# getting-started
p
I have
Copy code
private val _toneMap = MutableStateFlow(hashMapOf(0 to listOf<Tone>()))
and I update the value like this
Copy code
toneMap[index] = tones
val toneMapCopy = HashMap(toneMap)
_toneMap.value = toneMapCopy
there is an issue when the toneMap[index] already contains a list, the value is not updated. Any idea how to fix this?
h
You can't. StateFlow only emits a new value, when you call (emit/setValue) and the new value has a different hashcode. So you should emit a copy instead.
p
how can I emit a copy?