DataStore

interface DataStore

Simple interface for a data persistence "engine" that can read and write to disk

To keep things very simple, this interface only expects a key/value storage with strings. JSON-encoding is the simplest way to leverage this store with non-string data, which of course means accessors must implement type safety checks as necessary.

Functions

Link copied to clipboard
abstract fun clear(key: String)

Remove a key from the persistent store

Link copied to clipboard
abstract fun fetch(key: String): String?

Retrieve the value for the given key from the persistent store

Link copied to clipboard
abstract fun offStoreChange(observer: StoreObserver)

De-register an observer previously added with onStoreChange

Link copied to clipboard
abstract fun onStoreChange(observer: StoreObserver)

Register an observer to be notified when any changes are made to persistent store

Link copied to clipboard
abstract fun store(key: String, value: String)

Save a key/value pair to the persistent store