feat(shared): add KvPrefs expect/actual with change listeners (Android SharedPreferences)

This commit is contained in:
2025-09-08 18:51:31 +02:00
parent 8bcce89a08
commit 0c469b3572
2 changed files with 104 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package app.klottr.prefs
expect object KvPrefs {
/** Körs tidigt på varje plattform (Android: applicationContext). */
fun init(platformArg: Any? = null)
fun getString(key: String, def: String? = null): String?
fun putString(key: String, value: String?)
fun getInt(key: String, def: Int = 0): Int
fun putInt(key: String, value: Int)
fun getBoolean(key: String, def: Boolean = false): Boolean
fun putBoolean(key: String, value: Boolean)
fun getStringSet(key: String): Set<String>
fun putStringSet(key: String, value: Set<String>)
fun remove(key: String)
fun clearAll()
/** Enkelt changes-API som funkar i common kod. */
fun addListener(listener: (key: String?) -> Unit)
fun removeListener(listener: (key: String?) -> Unit)
}