SavedState



An opaque (empty) common type that holds saveable values to be saved and restored by native platforms that have a concept of System-initiated Process Death.

That means, the OS will give the chance for the process to keep the state of the application (normally using a serialization mechanism), and allow the app to restore its state later. That is commonly referred to as "state restoration".

A SavedState is required as the source input for a SavedStateReader or SavedStateWriter.

This class represents a container for persistable state data. It is designed to be platform-agnostic, allowing seamless state saving and restoration across different environments.

Summary

Extension functions

inline T
<T : Any?> SavedState.read(block: SavedStateReader.() -> T)

Performs read operations on this SavedState using a SavedStateReader.

Cmn
inline T
<T : Any?> SavedState.write(block: SavedStateWriter.() -> T)

Performs write operations on this SavedState using a SavedStateWriter.

Cmn

Extension functions

SavedState.read

inline fun <T : Any?> SavedState.read(block: SavedStateReader.() -> T): T

Performs read operations on this SavedState using a SavedStateReader.

IMPORTANT: The SavedStateReader passed as a receiver to the block is valid only inside that function. Using it outside of the function may produce unspecified behavior.

Parameters
block: SavedStateReader.() -> T

A lambda function that performs read operations using the SavedStateReader.

Returns
T

The result of the block execution.

SavedState.write

inline fun <T : Any?> SavedState.write(block: SavedStateWriter.() -> T): T

Performs write operations on this SavedState using a SavedStateWriter.

IMPORTANT: The SavedStateWriter passed as a receiver to the block is valid only inside that function. Using it outside of the function may produce unspecified behavior.

Parameters
block: SavedStateWriter.() -> T

A lambda function that performs write operations using the SavedStateWriter.

Returns
T

The result of the block execution.