lazyDeferred

fun <T> lazyDeferred(action: suspend () -> T): LazyDeferred<T>(source)

Lazily invokes action the first time await or join is called.

This action is only invoked once. The caller's coroutine is used to execute this action.

val expensive = lazyDeferred { repository.getAll() }

suspend fun getExpensive() = expensive.await()

Since

0.12.0