ContextualValSuspend
A val
for which the value can be set via the coroutineContext.
This is similar to a thread-local or the "dynamic scope" concept.
The default value is created lazily on demand per CoroutineScope (not globally!). For this to work you have to inject ContextualValRoot into each CoroutineScope that wants to support this class.
The name is only used to help with debugging.
Also see ContextualVal for a blocking version (not suspend).
Types
Link copied to clipboard
class ContextElement<T>(val key: ContextualValSuspend.ContextKey<T>, valueGetter: suspend (CoroutineContext) -> T) : CoroutineContext.Element
Link copied to clipboard
class ContextKey<T>(val value: ContextualValSuspend<T>) : CoroutineContext.Key<ContextualValSuspend.ContextElement<T>>
Properties
Functions
Link copied to clipboard
The returned CoroutineContext.Element can used to set a value via CoroutineScope.plus.