RetainStateProvider

Interface

Common
public interface RetainStateProvider

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.

Functions

public fun addRetainStateObserver(observer: RetainStateObserver)

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.

public fun removeRetainStateObserver(observer: RetainStateObserver)

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.