tornadofx2
tornadofx2 copied to clipboard
Incorrect behavior of bindChildren(ObservableMap)
Having this:
private val backedMap = LinkedHashMap<String, Int>().asObservable()
private val mapProperty: SimpleMapProperty<String, Int> = SimpleMapProperty(backedMap)
private val map: MutableMap<String, Int> by mapProperty
vbox(spacing = 10) {
bindChildren(mapProperty) { key, value ->
label("$key: $value")
}
}
I get two bugs\unexpected things:
- Ordering of converted items is not preserved. I end up with different ordering in my map and vbox's children. But I use LinkedHashMap for backed map and expect that binding would preserve ordering of backed collection.
- Instead of updating items in vbox's children it just adds a new one each time I put already presented key in map (== update value).
For the first one the possible reason is using val sourceToTarget = HashMap<SourceTypeKey, TargetType>()
in MapConversionListener
for observable lists which vbox's one may be. So it doesn't honor which type of map a user uses.
For the second It seems that it is referenced with Improving MapConversionListener #1183 but changes were not picked up to tornadofx2.
I wanted to at least try to fix it, but I couldn’t even build and connect tornadofx to my project locally :) So, could you please consider #7 Thank you!