CircuitSaver
Converts Screens and PopResults to and from representations that can be stored in a Compose SaveableStateRegistry.
Circuit's saveable back and nav stack implementations use this to persist navigation state. Implementations choose the stored representation. Returned values must be supported by the platform's SaveableStateRegistry.
Savers fail fast at save time when handed a value they do not support, since the developer can fix the value's type immediately. Restoration degrades instead. Saved data can come from an older app version, so unrestorable values restore as null and stacks fall back to their initial state.
Functions
Link copied to clipboard
Returns a saver that tries this saver and then other.
Link copied to clipboard
inline fun <T : PopResult> CircuitSaver.restorePopResult(saved: Any, onAbsent: () -> Unit = {}, onTypeMismatch: (CircuitSaveable) -> Unit = {
error("Expected ${T::class}, but CircuitSaver restored ${it::class}.")
}): T?
Link copied to clipboard
inline fun <T : Screen> CircuitSaver.restoreScreen(saved: Any, onAbsent: () -> Unit = {}, onTypeMismatch: (CircuitSaveable) -> Unit = {
error("Expected ${T::class}, but CircuitSaver restored ${it::class}.")
}): T?
Link copied to clipboard
Returns a saveable representation of value, or null to skip persisting it.