class GuavaDataStoreAny>

The class that wraps around DataStore to provide an interface that returns ListenableFutures for DataStore reads and writes.

Summary

Nested types

Builder class for a GuavaDataStore.

Public companion functions

GuavaDataStore
Any> from(dataStore: DataStore, coroutineContext: CoroutineContext)

Wraps a GuavaDataStore around a DataStore.

Public functions

ListenableFuture

Returns a ListenableFuture to get the latest persisted data.

ListenableFuture
updateDataAsync(transform: (input) -> T)

Returns a ListenableFuture to update the data using the provided transform.

Public companion functions

from

Added in 1.2.0-alpha02
fun Any> from(
    dataStore: DataStore,
    coroutineContext: CoroutineContext = Dispatchers.IO
): GuavaDataStore

Wraps a GuavaDataStore around a DataStore. This method does not create a new DataStore, so all getDataAsync and updateDataAsync called from the resulting GuavaDataStore will be sequenced by the underlying DataStore. It is thread-safe.

Parameters
dataStore: DataStore

the DataStore used to create GuavaDataStore

coroutineContext: CoroutineContext = Dispatchers.IO

the CoroutineContext used to launch the calls to DataStore. The default value is Dispatchers.IO

Returns
GuavaDataStore

the GuavaDataStore created with the provided parameters

Public functions

getDataAsync

Added in 1.2.0-alpha02
fun getDataAsync(): ListenableFuture

Returns a ListenableFuture to get the latest persisted data. It is not blocked by any ongoing updates.

updateDataAsync

Added in 1.2.0-alpha02
fun updateDataAsync(transform: (input) -> T): ListenableFuture

Returns a ListenableFuture to update the data using the provided transform. The transform is given the latest persisted data to produce its output, which is then persisted and returned. Concurrent updates are serialized (at most one update running at a time).