I'm trying to create lazy function my coroutines. I created util function like this.
fun <T> lazyCoroutine(scope: CoroutineScope, block: suspend CoroutineScope.() -> T): Lazy<T> {
val some = scope.async(start = CoroutineStart.LAZY) {
block.invoke(this)
}
return lazy {
some.await()
}
}
But in the terminal show
I'm also don't want to return Deferred<T>
, I only want to return just out come of deferred
. I saw most of the article return Deferred<T>
which is not suitable with my scenario. Is there any relevant solution please point me out. Have a great day!.