mirror of
https://github.com/tursom/TursomServer.git
synced 2025-03-14 03:40:06 +08:00
add listen
This commit is contained in:
parent
306b3cddd6
commit
cc9a6d47d2
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
implementation(project(":ts-core"))
|
||||
implementation(project(":ts-core:ts-delegation"))
|
||||
api(project(":ts-core:ts-delegation"))
|
||||
}
|
||||
|
||||
@kotlin.Suppress("UNCHECKED_CAST")
|
||||
|
@ -43,6 +43,11 @@ fun <T, V> listenable(delegatedField: MutableDelegatedField<T, V>): MutableDeleg
|
||||
infix operator fun <T, V> ListenableListener<T, V>.plus(listener: T.(old: V, new: V) -> Unit): Listener<T, V> =
|
||||
addListener(listener)
|
||||
|
||||
@OptIn(Listenable::class)
|
||||
infix fun <V> KProperty0<V>.listen(listener: Any.(old: V, new: V) -> Unit) {
|
||||
getListenableMutableDelegatedField()!!.addListener(listener)
|
||||
}
|
||||
|
||||
@OptIn(Listenable::class)
|
||||
fun <V> KProperty0<V>.getListenableMutableDelegatedField(): ListenableMutableDelegatedField<Any, V>? {
|
||||
isAccessible = true
|
||||
|
Loading…
Reference in New Issue
Block a user