Marshall
01/07/2021, 10:17 PMprivate val isRunningWrapperProperty = ReadOnlyBooleanWrapper(false)
var isRunning by isRunningWrapperProperty
private set
fun isRunningProperty(): ReadOnlyBooleanProperty = isRunningWrapperProperty.readOnlyProperty
melatonina
01/13/2021, 10:28 PMval isRunningProperty: ReadOnlyBooleanProperty get() = isRunningWrapperProperty.readOnlyProperty
instead of a function (if you don't care how you access it from Java), I don't think there is any better way.
Another variant is the following, separating public and private interface:
private val isRunningImplProperty = ReadOnlyBooleanWrapper(false)
private var isRunningImpl by isRunningImplProperty
val isRunning by isRunningWrapperProperty
val isRunningProperty: ReadOnlyBooleanProperty get() = isRunningWrapperProperty.readOnlyProperty
Again, nothing very meaningful. Just matter of taste.
I don't see how you could gain anything even using a custom delegation.jschneider
01/25/2021, 11:57 AMval runningProperty: ReadOnlyBooleanProperty = SimpleBooleanProperty().also{ [bind me]}
val running by val runningProperty