Delegates.observable event is fired before a property actually have changed?

Hi, I'm compiling Kotlin code to Javascript and are experiencing that events from Delegates.observable is fired before the property is actually changed.


var selected: Boolean? by Delegates.observable(selected) {
    property, old, new ->
    console.log("Action[${this.label}] selected changed: new = ${new}, this.selected = ${this.selected}")
    notifyPropertyChanged(property, old, new)

Is that intentional or a bug?

The documentation of method Delegates.observable says: “onChange the callback which is called when the property value is changed.
and it’s also most practial in my opinion!?



Hi Jørund,

it’s a mistake in documentation.
It should be: “Callback is called when a change to the property value is attempted. The new value is saved if the callback returns true and discarded if the callback returns false.”

Thanks for the clarification!