Update SuspendLazy
This commit is contained in:
@@ -30,4 +30,8 @@ class SoftSuspendLazy<T : Any>(
|
||||
}
|
||||
|
||||
suspend fun tryGet() = runCatchingCancellable { get() }
|
||||
|
||||
fun peek(): T? {
|
||||
return cachedValue?.get()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +32,10 @@ class SuspendLazy<T>(
|
||||
|
||||
suspend fun tryGet() = runCatchingCancellable { get() }
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun peek(): T? {
|
||||
return cachedValue?.takeUnless { it === Uninitialized } as T?
|
||||
}
|
||||
|
||||
private object Uninitialized
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user