DataStore.Builder



Builder for DataStore.

Summary

Public constructors

<T : Any?> Builder(storage: Storage<T>, context: CoroutineContext)
Cmn
android
JS
<T : Any?> Builder(
    storage: Storage<T>,
    context: ERROR CLASS: Symbol not found for CoroutineContext
)
N

Public functions

DataStore.Builder<T>
addMigrations(migrations: List<DataMigration<T>>)

Adds DataMigrations to the DataStore.

Cmn
android
N
JS
DataStore<T>

Validates the configuration and builds the Builder instance.

Cmn
android
N
JS
DataStore.Builder<T>

Sets the CorruptionHandler for the DataStore.

Cmn
android
N
JS
DataStore.Builder<T>
setTracer(tracer: Tracer)

Sets the Tracer for Android.

android

Public constructors

Builder

<T : Any?> Builder(storage: Storage<T>, context: CoroutineContext)

Builder

<T : Any?> Builder(
    storage: Storage<T>,
    context: ERROR CLASS: Symbol not found for CoroutineContext
)

Public functions

addMigrations

fun addMigrations(migrations: List<DataMigration<T>>): DataStore.Builder<T>

Adds DataMigrations to the DataStore.

Migrations are run in the order they are added before any data is returned to the user.

Parameters
migrations: List<DataMigration<T>>

the list of migrations.

Returns
DataStore.Builder<T>

this Builder instance.

build

fun build(): DataStore<T>

Validates the configuration and builds the Builder instance.

Returns
DataStore<T>

a new DataStore instance.

setCorruptionHandler

fun setCorruptionHandler(handler: CorruptionHandler<T>): DataStore.Builder<T>

Sets the CorruptionHandler for the DataStore.

This handler is invoked if the Storage layer throws a CorruptionException. Defaults to ReThrowCorruptionHandler.

Parameters
handler: CorruptionHandler<T>

the corruption handler.

Returns
DataStore.Builder<T>

this Builder instance.

setTracer

fun setTracer(tracer: Tracer): DataStore.Builder<T>

Sets the Tracer for Android.

Parameters
tracer: Tracer

The Tracer to use.

Returns
DataStore.Builder<T>

this Builder instance.