Skip to content

DataStoreHandler

Xavier F. Gouchet edited this page Sep 4, 2024 · 1 revision

interface DataStoreHandler

Interface for the datastore.

Types

DataStoreHandler.Companion

Functions

clearAllData

abstract fun clearAllData()

Removes all saved datastore entries.

removeValue

abstract fun removeValue(key: String, callback: DataStoreWriteCallback? = null)

Remove an entry from the datastore. This executes on a worker thread and not on the caller thread.

Parameters
key name of the datastore entry
callback (optional) to indicate whether the operation succeeded or not.

setValue

abstract fun <T : Any> setValue(key: String, data: T, version: Int = 0, callback: DataStoreWriteCallback? = null, serializer: Serializer<T>)

Write data to the datastore. This executes on a worker thread and not on the caller thread.

Parameters
T datatype of the data to write to the datastore.
key name of the datastore entry.
data to write.
version optional version for the entry. If not specified will give the entry version 0 - even if that would be a downgrade from the previous version.
callback (optional) to indicate whether the operation succeeded or not.
serializer to use to serialize the data.

value

abstract fun <T : Any> value(key: String, version: Int? = null, callback: DataStoreReadCallback<T>, deserializer: Deserializer<String, T>)

Read data from the datastore. This executes on a worker thread and not on the caller thread.

Parameters
T datatype of the data to read from the datastore.
key name of the datastore entry.
version optional version to use when reading from the datastore. If specified, will only return data if the persistent entry exactly matches this version number.
callback to return result asynchronously.
deserializer to use to deserialize the data.
Clone this wiki locally