RxDataStoreBuilder

public final class RxDataStoreBuilder<T extends Object>


Builder class for an RxDataStore that works on a single process.

Summary

Public constructors

<T extends Object> RxDataStoreBuilder(
    Callable<File> produceFile,
    Serializer<T> serializer
)

Create a RxDataStoreBuilder with the callable which returns the File that DataStore acts on.

<T extends Object> RxDataStoreBuilder(
    Context context,
    String fileName,
    Serializer<T> serializer
)

Create a RxDataStoreBuilder with the Context and name from which to derive the DataStore file.

Public methods

final @NonNull RxDataStoreBuilder<@NonNull T>
addDataMigration(DataMigration<T> dataMigration)

Add a DataMigration to the Datastore.

final @NonNull RxDataStoreBuilder<@NonNull T>
addRxDataMigration(RxDataMigration<T> rxDataMigration)

Add an RxDataMigration to the DataStore.

final @NonNull RxDataStore<@NonNull T>

Build the DataStore.

final @NonNull RxDataStoreBuilder<@NonNull T>
setCorruptionHandler(
    ReplaceFileCorruptionHandler<T> corruptionHandler
)

Sets the corruption handler to install into the DataStore.

final @NonNull RxDataStoreBuilder<@NonNull T>

Set the Scheduler on which to perform IO and transform operations.

Public constructors

RxDataStoreBuilder

public final <T extends Object> RxDataStoreBuilder(
    Callable<File> produceFile,
    Serializer<T> serializer
)

Create a RxDataStoreBuilder with the callable which returns the File that DataStore acts on. The user is responsible for ensuring that there is never more than one DataStore acting on a file at a time.

Parameters
Callable<File> produceFile

Function which returns the file that the new DataStore will act on. The function must return the same path every time. No two instances of DataStore should act on the same file at the same time.

Serializer<T> serializer

the serializer for the type that this DataStore acts on.

RxDataStoreBuilder

public final <T extends Object> RxDataStoreBuilder(
    Context context,