LazyDeferred

interface LazyDeferred<out T>(source)

Lazily invokes some 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

Inheritors

Properties

Link copied to clipboard
abstract val isCompleted: Boolean

Functions

Link copied to clipboard
Link copied to clipboard
abstract suspend fun await(): T
Link copied to clipboard
abstract fun getCompleted(): T

Immediately returns the deferred value if already completed.