W3cubDocs

/Kotlin

ObservableProperty

abstract class ObservableProperty<T> : 
    ReadWriteProperty<Any?, T>

Implements the core logic of a property delegate for a read/write property that calls callback functions when changed.

Parameters

initialValue - the initial value of the property.

Constructors

<init>

ObservableProperty(initialValue: T)

Implements the core logic of a property delegate for a read/write property that calls callback functions when changed.

Functions

afterChange

open fun afterChange(
    property: KProperty<*>, 
    oldValue: T, 
    newValue: T)

The callback which is called after the change of the property is made. The value of the property has already been changed when this callback is invoked.

beforeChange

open fun beforeChange(
    property: KProperty<*>, 
    oldValue: T, 
    newValue: T
): Boolean

The callback which is called before a change to the property value is attempted. The value of the property hasn't been changed yet, when this callback is invoked. If the callback returns true the value of the property is being set to the new value, and if the callback returns false the new value is discarded and the property remains its old value.

getValue

open fun getValue(thisRef: Any?, property: KProperty<*>): T

Returns the value of the property for the given object.

setValue

open fun setValue(
    thisRef: Any?, 
    property: KProperty<*>, 
    value: T)

Sets the value of the property for the given object.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-observable-property/