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

androidx.compose.runtime.dispatch

Interfaces

MonotonicFrameClock

Provides a time source for display frames and the ability to perform an action on the next frame.

Classes

AndroidUiDispatcher

A CoroutineDispatcher that will perform dispatch during a handler callback or choreographer's animation frame stage, whichever comes first.

AndroidUiFrameClock

BroadcastFrameClock

A simple frame clock.

Top-level functions summary

suspend R
withFrameMillis(onFrame: (frameTimeMillis: Long) -> R)

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

suspend R
withFrameNanos(onFrame: (frameTimeMillis: Long) -> R)

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

Top-level properties summary

actual MonotonicFrameClock

Extension functions summary

For MonotonicFrameClock
suspend R
MonotonicFrameClock.withFrameMillis(crossinline onFrame: (frameTimeMillis: Long) -> R)

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

Top-level functions

withFrameMillis

suspend fun <R> withFrameMillis(onFrame: (frameTimeMillis: Long) -> R): R

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

frameTimeNanos should be used when calculating animation time deltas from frame to frame as it may be normalized to the target time for the frame, not necessarily a direct, "now" value.

The time base of the value provided by MonotonicFrameClock.withFrameMillis is implementation defined. Time values provided are monotonically increasing; after a call to MonotonicFrameClock.withFrameMillis completes it must not provide the same value again for a subsequent call.

This function will invoke MonotonicFrameClock.withFrameNanos using the calling CoroutineContext's MonotonicFrameClock or a default frame clock if one is not present in the CoroutineContext.

withFrameNanos

suspend fun <R> withFrameNanos(onFrame: (frameTimeMillis: Long) -> R): R

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

frameTimeNanos should be used when calculating animation time deltas from frame to frame as it may be normalized to the target time for the frame, not necessarily a direct, "now" value.

The time base of the value provided by withFrameNanos is implementation defined. Time values provided are monotonically increasing; after a call to withFrameNanos completes it must not provide the same value again for a subsequent call.

This function will invoke MonotonicFrameClock.withFrameNanos using the calling CoroutineContext's MonotonicFrameClock or a default frame clock if one is not present in the CoroutineContext.

Top-level properties

DefaultMonotonicFrameClock

actual val DefaultMonotonicFrameClock: MonotonicFrameClock

Extension functions

withFrameMillis

inline suspend fun <R> MonotonicFrameClock.withFrameMillis(crossinline onFrame: (frameTimeMillis: Long) -> R): R

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

frameTimeNanos should be used when calculating animation time deltas from frame to frame as it may be normalized to the target time for the frame, not necessarily a direct, "now" value.

The time base of the value provided by MonotonicFrameClock.withFrameMillis is implementation defined. Time values provided are monotonically increasing; after a call to MonotonicFrameClock.withFrameMillis completes it must not provide the same value again for a subsequent call.