add MapOneToManyKeyValueRepo

This commit is contained in:
2020-10-14 19:37:25 +06:00
parent 8461ff4d38
commit e22595339e
3 changed files with 89 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package dev.inmo.micro_utils.repos
import dev.inmo.micro_utils.pagination.Pagination
import dev.inmo.micro_utils.pagination.PaginationResult
import kotlinx.coroutines.flow.Flow
interface OneToManyReadKeyValueRepo<Key, Value> : Repo {
suspend fun get(k: Key, pagination: Pagination, reversed: Boolean = false): PaginationResult<Value>
@@ -13,6 +14,10 @@ interface OneToManyReadKeyValueRepo<Key, Value> : Repo {
}
interface OneToManyWriteKeyValueRepo<Key, Value> : Repo {
val onNewValue: Flow<Pair<Key, Value>>
val onValueRemoved: Flow<Pair<Key, Value>>
val onDataCleared: Flow<Key>
suspend fun add(k: Key, v: Value)
suspend fun remove(k: Key, v: Value)
suspend fun clear(k: Key)