GlanceStateDefinition

interface GlanceStateDefinition<T : Any?>

Known direct subclasses
PreferencesGlanceStateDefinition

Base class helping the creation of a state using DataStore's Preferences.


Configuration definition for GlanceState. This defines where the data is stored and how the underlying data store is created. Use a unique GlanceStateDefinition to get a GlanceState, once defined, the data should be updated using the state directly, this definition should not change.

Summary

Public functions

suspend DataStore<T>
getDataStore(context: Context, fileKey: String)

Creates the underlying data store.

File
getLocation(context: Context, fileKey: String)

This file indicates the location of the persisted data.

Public functions

getDataStore

suspend fun getDataStore(context: Context, fileKey: String): DataStore<T>

Creates the underlying data store.

Parameters
context: Context

The context used to create locate the file directory

fileKey: String

The unique string key used to name and identify the data file corresponding to a remote UI. Each remote UI has a unique UI key, used to key the data for that UI.

getLocation

Added in 1.0.0
fun getLocation(context: Context, fileKey: String): File

This file indicates the location of the persisted data.

Parameters
context: Context

The context used to create the file directory

fileKey: String

The unique string key used to name and identify the data file corresponding to a remote UI. Each remote UI has a unique UI key, used to key the data for that UI.