Hi, I want to send a model instance (which is boun...
# tornadofx
m
Hi, I want to send a model instance (which is bound to an ItemViewModel) as payload in a POST call whenever the property inside the model changes. I have the following setup:
Copy code
class MainControl : JsonModel {

    val controlProperty = SimpleDoubleProperty(0.0)
    var control by controlProperty
    
    override fun toJSON(json: JsonBuilder) {
        with(json) {
            add("controlValue", control)
        }
    }
}

class MainControlModel : ItemViewModel<MainControl>() {

    val mainControl = bind(MainControl::controlProperty)
}

class MainController : Controller() {

    private val api: Rest by inject()

    private val control: MainControlModel by inject()

    init {
        with(api) {
            baseURI = "<http://localhost:8090>"
        }

        control.mainControl.addListener { _, _, _ ->
            LOG.debug("{}", control.item)
            <http://api.post|api.post>("control", control.item)
        }
    }
}
But
control.item
is always null? How can I do this?