# PausableMonotonicFrameClock

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/PausableMonotonicFrameClock.kt+class:androidx.compose.runtime.PausableMonotonicFrameClock) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class PausableMonotonicFrameClock : MonotonicFrameClock
  ```

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock` wrapper that can be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#pause()`d and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#resume()`d.

A paused clock will not dispatch `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` events until it is resumed. Pausing a clock does **not** stop or change the frame times reported to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` calls; the clock times reported will always remain consistent with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#frameClock()`.

`https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock` should be used in cases where frames should not be produced under some conditions, such as when a window hosting a UI is not currently visible. As clock times are not altered from the source `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#frameClock()`, animations in progress may be fully complete by the time the clock is resumed and a new frame is produced.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#PausableMonotonicFrameClock(androidx.compose.runtime.MonotonicFrameClock)(frameClock: https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock)` | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#pause()()` Pause the generation of frames. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#resume()()` Resume the generation of frames. | Cmn |
| `open suspend R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)(onFrame: (frameTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) -> R)` Suspends until a new frame is requested, immediately invokes `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)` with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#isPaused()` `true` if this clock is currently `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#pause()` or `false` if this clock is currently `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#resume()`. | Cmn |

### Inherited functions

From [kotlin.coroutines.CoroutineContext](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html) `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/plus.html(context: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html)` Cmn From [kotlin.coroutines.CoroutineContext.Element](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/index.html) `open R` `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/fold.html(initial: R, operation: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/index.html, R) -> R)` Cmn `open operator E?` `<E : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/index.html> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/get.html(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-key/index.html<E>)` Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-element/minus-key.html(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-key/index.html<*>)` Cmn

### Inherited properties

From [androidx.compose.runtime.MonotonicFrameClock](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/-key/index.html<*>` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#key()` Cmn

## Public constructors

### PausableMonotonicFrameClock

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
PausableMonotonicFrameClock(frameClock: MonotonicFrameClock)
```

## Public functions

### pause

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
fun pause(): Unit
```

Pause the generation of frames. Pausing a clock that is already paused has no effect. While the clock is paused any calls to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` will suspend until the clock is resumed before delegating to the wrapped `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#frameClock()`'s `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` method. Call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#resume()` to resume generating frames.

### resume

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
fun resume(): Unit
```

Resume the generation of frames. Any queued calls to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` will resume and delegate to the wrapped `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#frameClock()`'s `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#withFrameNanos(kotlin.Function1)` method.

### withFrameNanos

Cmn

```
open suspend fun <R : Any?> withFrameNanos(onFrame: (frameTimeNanos: Long) -> R): R
```

Suspends until a new frame is requested, immediately invokes `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)` with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)`.

`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 `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)` is implementation defined. Time values provided are strictly monotonically increasing; after a call to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MonotonicFrameClock#withFrameNanos(kotlin.Function1)` completes it must not provide the same value again for a subsequent call.

## Public properties

### isPaused

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
val isPaused: Boolean
```

`true` if this clock is currently `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#pause()` or `false` if this clock is currently `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableMonotonicFrameClock#resume()`. A PausableMonotonicFrameClock is not paused at construction time.