INNER CODE UNIT · Kotlin
CoroutineLiveData
M66B/FairEmail · app/src/main/java/androidx/lifecycle/CoroutineLiveData.kt:194
internal class CoroutineLiveData<T>(
context: CoroutineContext = EmptyCoroutineContext,
timeoutInMs: Long = DEFAULT_TIMEOUT,
block: Block<T>,
) : MediatorLiveData<T>() {
private var blockRunner: BlockRunner<T>?
private var emittedSource: EmittedSource? = null
init {
// use an intermediate supervisor job so that if we cancel individual block runs due to
// losing
// observers, it won't cancel the given context as we only cancel w/ the intention of
// possibly
// relaunching using the same parent context.
val supervisorJob = SupervisorJob(context[Job])
// The scope for this LiveData where we launch every block Job.
// We default to Main dispatcher but developer can override it.