mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 06:40:07 +00:00
fix of #155 and build
This commit is contained in:
parent
1be1070eb4
commit
3870db1c88
@ -6,6 +6,9 @@
|
||||
* Add opportunity to use markers in actors (solution of [#160](https://github.com/InsanusMokrassar/MicroUtils/issues/160))
|
||||
* `Koin`:
|
||||
* Module inited :)
|
||||
* `Repos`:
|
||||
* `Android`:
|
||||
* Add typealias `KeyValueSPRepo` and opportunity to create shared preferences `KeyValue` repo with `KeyValueStore(...)` (fix of [#155](https://github.com/InsanusMokrassar/MicroUtils/issues/155))
|
||||
|
||||
## 0.12.12
|
||||
|
||||
|
@ -19,5 +19,10 @@ kotlin {
|
||||
api libs.kt.reflect
|
||||
}
|
||||
}
|
||||
androidMain {
|
||||
dependencies {
|
||||
api libs.kt.reflect
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ fun <T : Any> Context.keyValueStore(
|
||||
): KeyValueRepo<String, T> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return cache.getOrPut(name) {
|
||||
KeyValueStore<T>(this, name, cacheValues)
|
||||
KeyValueStore<T>(c = this, preferencesName = name, useCache = cacheValues)
|
||||
} as KeyValueStore<T>
|
||||
}
|
||||
|
||||
@ -149,6 +149,14 @@ class KeyValueStore<T : Any> internal constructor (
|
||||
_onValueRemovedFlow.emit(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
operator fun <T : Any> invoke(
|
||||
context: Context,
|
||||
name: String = "default",
|
||||
cacheValues: Boolean = false
|
||||
) = context.keyValueStore<T>(name, cacheValues)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T : Any> SharedPreferencesKeyValueRepo(
|
||||
@ -156,3 +164,5 @@ inline fun <T : Any> SharedPreferencesKeyValueRepo(
|
||||
name: String = "default",
|
||||
cacheValues: Boolean = false
|
||||
) = context.keyValueStore<T>(name, cacheValues)
|
||||
|
||||
typealias KeyValueSPRepo<T> = KeyValueStore<T>
|
||||
|
Loading…
Reference in New Issue
Block a user