Commit 3731bd98 authored by Him188's avatar Him188

Add WeakRef

parent eb9a64e5
......@@ -11,6 +11,13 @@ inline class UnsafeWeakRef<T>(private val weakRef: WeakRef<T>) {
fun get(): T = weakRef.get() ?: error("WeakRef is released")
fun clear() = weakRef.clear()
/**
* Provides delegate value.
*
* ```kotlin
* val bot: Bot by param.unsafeWeakRef()
* ```
*/
operator fun getValue(thisRef: Any?, property: KProperty<*>): T? = this.get()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment