LithoSaveableStateRegistry

Registry of component state that can be snapshotted into Android saved state.

Android's androidx.savedstate.SavedStateRegistry is owned and accessed by a lifecycle host on the main thread. Litho may resolve components on multiple background threads, so a host restores one Bundle into this registry and registers this registry's snapshot as one Android saved state provider. Components then register value providers without directly accessing the Android registry.

This type is thread-safe. Provider code is evaluated outside the registry lock, while each individual provider is serialized to prevent concurrent saver calls. The owner defines the registry lifetime and must close it when the corresponding tree or navigation entry is permanently removed.

Parameters

restoredState

a snapshot produced by a previous registry instance and restored through Android's saved-state mechanism, or null for a new state scope.

valueClassLoader

the host android.content.Context class loader used to deserialize custom values from the restored Bundle. Hosts should pass Context.getClassLoader(); null uses the Bundle's default class loader.

Constructors

Link copied to clipboard
constructor(restoredState: Bundle? = null, valueClassLoader: ClassLoader? = null)

Functions

Link copied to clipboard
open override fun close()

Clears this registry and rejects future registrations, restored-state reads, and snapshots.

Link copied to clipboard

Creates an independently keyed registry whose snapshot is owned by this registry.

Link copied to clipboard

Returns a Bundle containing retained values and the latest value from every active provider.