Google is committed to advancing racial equity for Black communities. See how.

AndroidUiDispatcher

class AndroidUiDispatcher : CoroutineDispatcher
kotlin.Any
   ↳ kotlin.coroutines.AbstractCoroutineContextElement
   ↳ kotlinx.coroutines.CoroutineDispatcher
   ↳ androidx.compose.runtime.dispatch.AndroidUiDispatcher

A CoroutineDispatcher that will perform dispatch during a handler callback or choreographer's animation frame stage, whichever comes first. Use Main to obtain a dispatcher for the process's main thread (i.e. the activity thread) or CurrentThread to obtain a dispatcher for the current thread.

Summary

Public methods
Unit
dispatch(context: CoroutineContext, block: Runnable)

Properties
Choreographer

MonotonicFrameClock

A MonotonicFrameClock associated with this AndroidUiDispatcher's choreographer that may be used to await Choreographer frame dispatch.

Companion properties
CoroutineContext

The canonical CoroutineContext containing the AndroidUiDispatcher and its frameClock for the calling thread.

CoroutineContext

The CoroutineContext containing the AndroidUiDispatcher and its frameClock for the process's main thread.

Public methods

dispatch

fun dispatch(
    context: CoroutineContext,
    block: Runnable
): Unit

Properties

choreographer

val choreographer: Choreographer

frameClock

val frameClock: MonotonicFrameClock

A MonotonicFrameClock associated with this AndroidUiDispatcher's choreographer that may be used to await Choreographer frame dispatch.

Companion properties

CurrentThread

val CurrentThread: CoroutineContext

The canonical CoroutineContext containing the AndroidUiDispatcher and its frameClock for the calling thread. Returns Main if accessed from the process's main thread.

Throws IllegalStateException if the calling thread does not have both a Choreographer and an active Looper.

Main

val Main: CoroutineContext

The CoroutineContext containing the AndroidUiDispatcher and its frameClock for the process's main thread.