repos update

This commit is contained in:
2020-11-07 02:25:50 +06:00
parent fc8d0e52ef
commit 325f178763
12 changed files with 161 additions and 70 deletions

View File

@@ -43,21 +43,13 @@ interface WriteOneToManyKeyValueRepo<Key, Value> : Repo {
val onValueRemoved: Flow<Pair<Key, Value>>
val onDataCleared: Flow<Key>
suspend fun add(toAdd: Map<Key, List<Value>>) = toAdd.forEach { (k, values) ->
values.forEach { v ->
add(k, v)
}
}
suspend fun add(toAdd: Map<Key, List<Value>>)
@Deprecated("Will be extracted as extension for other add method")
suspend fun add(k: Key, v: Value)
suspend fun add(k: Key, v: Value) = add(mapOf(k to listOf(v)))
suspend fun remove(toRemove: Map<Key, List<Value>>) = toRemove.forEach { (k, values) ->
values.forEach { v ->
remove(k, v)
}
}
suspend fun remove(toRemove: Map<Key, List<Value>>)
@Deprecated("Will be extracted as extension for other remove method")
suspend fun remove(k: Key, v: Value)
suspend fun remove(k: Key, v: Value) = remove(mapOf(k to listOf(v)))
suspend fun clear(k: Key)
}

View File

@@ -16,8 +16,16 @@ interface WriteStandardKeyValueRepo<Key, Value> : Repo {
val onNewValue: Flow<Pair<Key, Value>>
val onValueRemoved: Flow<Key>
@Deprecated("Realize set with map instead")
suspend fun set(k: Key, v: Value)
suspend fun set(toSet: Map<Key, Value>) = toSet.forEach { (k, v) ->
set(k, v)
}
@Deprecated("Realize unset with list instead")
suspend fun unset(k: Key)
suspend fun unset(toUnset: List<Key>) = toUnset.forEach {
unset(it)
}
}
interface StandardKeyValueRepo<Key, Value> : ReadStandardKeyValueRepo<Key, Value>, WriteStandardKeyValueRepo<Key, Value>