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

DisposableAnimationClock

class DisposableAnimationClock : AnimationClockObservable
kotlin.Any
   ↳ androidx.compose.animation.DisposableAnimationClock

Clock that remembers all of its active subscriptions so that it can dispose of upstream subscriptions. Create auto-disposing clocks in composition using asDisposableClock.

Summary

Public constructors

Clock that remembers all of its active subscriptions so that it can dispose of upstream subscriptions.

Public methods
Unit

Unsubscribe all current subscriptions to the clock.

Unit

Subscribes an observer to the animation clock source.

Unit

Unsubscribes an observer from the animation clock.

Inherited extension functions
From androidx.compose.animation
DisposableAnimationClock

Return a new AnimationClockObservable wrapping this one that will auto-unsubscribe all AnimationClockObservers when this call leaves the composition, preventing clock subscriptions from persisting beyond the composition lifecycle.

Properties
Boolean

true if dispose has been called and no new subscriptions are permitted.

Public constructors

<init>

DisposableAnimationClock(clock: AnimationClockObservable)

Clock that remembers all of its active subscriptions so that it can dispose of upstream subscriptions. Create auto-disposing clocks in composition using asDisposableClock.

Public methods

dispose

fun dispose(): Unit

Unsubscribe all current subscriptions to the clock. No new subscriptions are permitted; further calls to subscribe will be ignored. After a call to dispose, isDisposed will return true.

subscribe

fun subscribe(observer: AnimationClockObserver): Unit

Subscribes an observer to the animation clock source.

Observers may only be added to a clock once. Calls to add the same observer more than once will be ignored, and a single call to unsubscribe will unregister from further callbacks.

Parameters
observer: AnimationClockObserver The observer that will be notified when animation clock time is updated.

unsubscribe

fun unsubscribe(observer: AnimationClockObserver): Unit

Unsubscribes an observer from the animation clock.

Observers may only be added to a clock once. If subscribe has been called multiple times with the same observer, a single call to this method will unregister the observer completely.

Parameters
observer: AnimationClockObserver The observer to be removed from the subscription list.

Properties

isDisposed

val isDisposed: Boolean

true if dispose has been called and no new subscriptions are permitted.