onRestore

inline fun SavedStateHandle.onRestore(key: String = DEFAULT_KEY, restore: () -> Unit): SavedStateHandle

Executes the given restore block if the state for key WAS restored from process death.

This is useful for triggering analytics, logging, or state invalidation operations when the screen recovers from a killed process. Ensure this is called after respawnMutableStateFlow.

Return

The SavedStateHandle for chaining.

Parameters

key

The state key to check.

restore

The action to perform upon restoration.