observe

fun <T> ComponentActivity.observe(key: Preferences.Key<T>, default: T, @WorkerThread callback: suspend (value: T) -> Unit): Job

Observes the values sent to key while the Activity is started. Will pause onPause, and restart after onStart.

Author

Arnau Mora

Since

20220829

Parameters

key

The preferences key to observe.

default

The value to return if no value is stored at key.

callback

Will get called whenever the value at key is updated.