From bc6e8aed51afdd6a1deab26dd39c9a718c3aad7e Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 22 Dec 2020 14:16:43 +0100 Subject: [PATCH] Forgot to commit ObjectReference which is already used for some time --- .../utils/multiplatform/ObjectReference.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 common/src/commonMain/kotlin/net/dankito/utils/multiplatform/ObjectReference.kt diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/ObjectReference.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/ObjectReference.kt new file mode 100644 index 00000000..d0d41352 --- /dev/null +++ b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/ObjectReference.kt @@ -0,0 +1,21 @@ +package net.dankito.utils.multiplatform + + +open class ObjectReference( + value: T?, + open val valueChangedListener: ((T?) -> Unit)? = null +) { + + open var value: T? = value + set(value) { + field = value + + valueChangedListener?.invoke(value) + } + + + override fun toString(): String { + return "$value" + } + +} \ No newline at end of file