This is the best I came up with so far
# javascript
a
This is the best I came up with so far
s
bind a property of an object to a callback
I'm not sure I'm following what you trying to achieve. What do you mean by "bind"? Could you point the name of the property you want to bind in your snippet?
a
I can give you a JavaFX equivalent.
Copy code
CuboidMesh(obj.xSize, obj.ySize, obj.zSize).apply {
                this.centerProperty().bind(center)
                this.materialProperty().bind(listener["color"].transform { it.material() })
            }
The idea is that I have some model object which could be updated externally and I want field of the display object to be updated automatically.
🙏 1
r
You could use observables as your model (https://github.com/rjaros/kotlin-observable-js)
a
I have my own variant of observables already. You can see
onChange
method in the code. The problem is how to automatically notify the properties of a library (three.js) objects. It is obviously not possible in basic kotlin, but possible in pure JS. I thought that there is some kind of trick there.
The objects in three.js could handle events via this prototype: https://threejs.org/docs/#api/en/core/EventDispatcher. But it does not seem to help me, since I still need to create a lambda specifying the change