RetainStateProvider

Known direct subclasses
RetainScope

A RetainScope acts as a storage area for objects being retained.

RetainStateProvider.AlwaysKeepExitedValues

An implementation of RetainStateProvider that is not backed by a RetainScope and is always set to keep exited values.

RetainStateProvider.NeverKeepExitedValues

An implementation of RetainStateProvider that is not backed by a RetainScope and is never set to keep exited values.

Known indirect subclasses
ControlledRetainScope

A ControlledRetainScope is effectively a "Mutable" RetainScope.

ForgetfulRetainScope

The ForgetfulRetainScope is an implementation of RetainScope that is incapable of keeping any exited values.


RetainStateProvider is an owner of the isKeepingExitedValues state used by RetainScope. This interface is extracted to allow retain state to be observed without the presence of the value storage. This is particularly useful as most RetainScopes respect a hierarchy where they begin keeping exited values when either their retain condition becomes true or their parent scope begins keeping exited values.

Summary

Nested types

An implementation of RetainStateProvider that is not backed by a RetainScope and is always set to keep exited values.

An implementation of RetainStateProvider that is not backed by a RetainScope and is never set to keep exited values.

Listener interface to observe changes in the value of RetainStateProvider.isKeepingExitedValues.

Public functions

Unit

Registers the given observer with this RetainStateProvider to be notified when the value of isKeepingExitedValues changes.

Cmn
Unit

Removes a previously registered observer.

Cmn

Public properties

Boolean

Returns whether the associated retain scenario is active, and associated scopes should retain objects as they are removed from the composition hierarchy.

Cmn

Public functions

addRetainStateObserver

fun addRetainStateObserver(
    observer: RetainStateProvider.RetainStateObserver
): Unit

Registers the given observer with this RetainStateProvider to be notified when the value of isKeepingExitedValues changes. The added observer will receive its first notification the next time isKeepingExitedValues is updated.

This method is not thread safe and should only be invoked on the applier thread.

removeRetainStateObserver

fun removeRetainStateObserver(
    observer: RetainStateProvider.RetainStateObserver
): Unit

Removes a previously registered observer. It will receive no further updates from this RetainStateProvider unless it is registered again in the future. If the observer is not currently registered, this this method does nothing.

This method is not thread safe and should only be invoked on the applier thread.

Public properties

isKeepingExitedValues

val isKeepingExitedValuesBoolean

Returns whether the associated retain scenario is active, and associated scopes should retain objects as they are removed from the composition hierarchy.