PersistenceStrategy

Pluggable storage backend for persisting and restoring serialized store state.

Implement this interface to provide platform-specific storage (e.g. SharedPreferences, a file on disk, or an in-memory store for tests) and pass it to the store builder:

val store = createStore {
persistence(MyPersistenceStrategy())
module(CounterModule)
}

All methods are suspend so that I/O can be performed on the appropriate dispatcher without blocking the calling coroutine.

Functions

Link copied to clipboard
abstract suspend fun hasPersistedState(): Boolean

Returns true if a previously persisted state is available to be loaded.

Link copied to clipboard
abstract suspend fun loadState(): String?

Load a previously persisted state string, or null if no state has been saved yet.

Link copied to clipboard
abstract suspend fun saveState(serializedState: String)

Persist the full serialized store state.