Delegates.observable having inexplicable side effects with tornadoFX

So I’m using a Boolean by Delegates.observable to automatically refresh a stackpane containing imageviews by just inverting the boolean whenever I want the pane refreshed.
This worked flawlessy until I switched from having root = borderpane() to root = tabpane() because when I trigger the observable now, every image that is (correctly) added to the stackpane it belongs to, also gets added as a new, empty tab in the tabpane. This way the tab bar gets spammed quickly and this does not happen when I add the images to the stackpane in any other way.


I started using Delegates after searching for a way to refresh the stackpane on change of another var but have little insight in their inner workings. Can someone explain why this happens and how to prevent it?

Well, all I can say here is that you have a bug in your code. val foo by Delegates.observable is basically nothing more than

val foo: Boolean 
    get() = field
    set(value) {
         // your code passed to Delegates.observable
         field = value

From what you told us I think you should look at your observable callback and maybe at the documentation recarding borderpane and tabpane, especially how they behave differently. I’ve never used tornadoFX before so I can’t help you there.
If this doesn’t help I suggest posting the code in the observable delegate.

This sounds like the boolean does not have any real meaning and it’s just there to refresh the view. In that case you should really consider using a function instead.

Thanks for the advice, my usage of Delegates was indeed completely unnecessary. For some reason I didn’t think of making a normal function back then and didn’t question it later.
My code is cleaner now but the bug persists, I suppose I need more knowledge about tornadoFX.