🌈 Create new beautiful Compose Gradients with our new wesite ->
Property

DefaultMonotonicFrameClock

Source set: Android
@Deprecated(
    "MonotonicFrameClocks are not globally applicable across platforms. " +
        "Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock by
    lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
        if (DisallowDefaultMonotonicFrameClock)
            error("Disallowed use of DefaultMonotonicFrameClock")

        // When linked against Android SDK stubs and running host-side tests, APIs such as
        // Looper.getMainLooper() that will never return null on a real device will return null.
        // This branch offers an alternative solution.
        if (Looper.getMainLooper() != null) DefaultChoreographerFrameClock else FallbackFrameClock
    }
Source set: Common
public val DefaultMonotonicFrameClock: MonotonicFrameClock

The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.

This value is no longer used by compose runtime.

Source set: Desktop
@Deprecated(
    "MonotonicFrameClocks are not globally applicable across platforms. " +
        "Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock
Source set: JS
@Deprecated(
    "MonotonicFrameClocks are not globally applicable across platforms. " +
        "Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
    object : MonotonicFrameClock {
        override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R =
            suspendCoroutine { continuation ->
                window.requestAnimationFrame {
                    val duration = it.toDuration(DurationUnit.MILLISECONDS)
                    val result = onFrame(duration.inWholeNanoseconds)
                    continuation.resume(result)
                }
            }
    }

The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.

This value is no longer used by compose runtime.

Source set: Native
@Deprecated(
    "MonotonicFrameClocks are not globally applicable across platforms. " +
        "Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
    object : MonotonicFrameClock {
        private val markNow = TimeSource.Monotonic.markNow()

        override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R {
            yield()
            return onFrame(markNow.elapsedNow().inWholeNanoseconds)
        }
    }

The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.

This value is no longer used by compose runtime.

Source set: WasmJs
@Deprecated(
    "MonotonicFrameClocks are not globally applicable across platforms. " +
        "Use an appropriate local clock."
)
public val DefaultMonotonicFrameClock: MonotonicFrameClock =
    object : MonotonicFrameClock {
        override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R =
            suspendCoroutine { continuation ->
                window.requestAnimationFrame {
                    val duration = it.toDuration(DurationUnit.MILLISECONDS)
                    val result = onFrame(duration.inWholeNanoseconds)
                    continuation.resume(result)
                }
            }
    }

The MonotonicFrameClock used by withFrameNanos and withFrameMillis if one is not present in the calling kotlin.coroutines.CoroutineContext.

This value is no longer used by compose runtime.

Content updated: