setValue

fun setValue(value: T)(source)

Sets the value of the observable property.

This function attempts to update the state with the new value.

  • If the new value is the same as the current state, no action is taken, but the onBindCallback is still invoked.

  • If the value is different:

    • It first calls all registered beforeChange listeners. If any of these listeners return false, the update is aborted, and the function returns.

    • If all beforeChange listeners allow the change (or if there are no such listeners), the state is updated to the new value.

    • After the state is updated, all registered afterChange listeners are invoked with the old and new values.

    • The onUpdated callback (if provided during construction) is invoked with the new value.

  • Regardless of whether the value changed or not, the onBindCallback (if set via bind) is invoked with the new (or current) value.

Parameters

value

The new value to set for the property.


fun setValue(thisRef: Any?, prop: KProperty<*>, value: T)(source)