Marks a StateStoreKey to be persisted to DataStore.

Keys implementing this interface will have their state automatically saved and restored if the StateStore calls the syncToDataStore function. The key provides the name its value is stored under and the KSerializer for the value:

@Serializable
object
SettingsKey : StateStoreKey<Settings>(Settings()), PersistToDataStore<Settings> {
override val name = "settings"
override val serializer = Settings.serializer()
}
Parameters
<T : Any?>

the type of the value held by the implementing StateStoreKey

Summary

Public properties

String

The name the value is stored under.

Cmn
KSerializer<T>

The serializer used to save and restore the value of the implementing StateStoreKey.

Cmn

Public properties

name

val name: String

The name the value is stored under.

It must be unique among the keys synced to the same DataStore and must not change between versions of the app, since persisted data is looked up by it.

serializer

val serializer: KSerializer<T>

The serializer used to save and restore the value of the implementing StateStoreKey.