WriteCRUDCacheRepo subscribtions and changeResultsUnchecked(Pagination)

This commit is contained in:
InsanusMokrassar 2022-09-05 15:07:33 +06:00
parent 23b2d60295
commit c9822a491b
3 changed files with 22 additions and 0 deletions

View File

@ -2,6 +2,12 @@
## 0.12.7 ## 0.12.7
* `Repos`:
* `Cache`:
* Force `WriteCRUDCacheRepo` to subscribe on new and updated objects of parent repo
* `Pagination`:
* New function `changeResultsUnchecked(Pagination)`
## 0.12.6 ## 0.12.6
* `MimeeTypes>`: * `MimeeTypes>`:

View File

@ -48,6 +48,14 @@ data class PaginationResult<T>(
} }
fun <T> emptyPaginationResult() = PaginationResult<T>(0, 0, emptyList(), 0L) fun <T> emptyPaginationResult() = PaginationResult<T>(0, 0, emptyList(), 0L)
fun <T> emptyPaginationResult(
basePagination: Pagination
) = PaginationResult<T>(
basePagination.page,
basePagination.size,
emptyList(),
0L
)
/** /**
* @return New [PaginationResult] with [data] without checking of data sizes equality * @return New [PaginationResult] with [data] without checking of data sizes equality

View File

@ -33,6 +33,14 @@ open class WriteCRUDCacheRepo<ObjectType, IdType, InputValueType>(
override val updatedObjectsFlow: Flow<ObjectType> by parentRepo::updatedObjectsFlow override val updatedObjectsFlow: Flow<ObjectType> by parentRepo::updatedObjectsFlow
override val deletedObjectsIdsFlow: Flow<IdType> by parentRepo::deletedObjectsIdsFlow override val deletedObjectsIdsFlow: Flow<IdType> by parentRepo::deletedObjectsIdsFlow
val createdObjectsFlowJob = parentRepo.newObjectsFlow.onEach {
kvCache.set(idGetter(it), it)
}.launchIn(scope)
val updatedObjectsFlowJob = parentRepo.updatedObjectsFlow.onEach {
kvCache.set(idGetter(it), it)
}.launchIn(scope)
val deletedObjectsFlowJob = parentRepo.deletedObjectsIdsFlow.onEach { val deletedObjectsFlowJob = parentRepo.deletedObjectsIdsFlow.onEach {
kvCache.unset(it) kvCache.unset(it)
}.launchIn(scope) }.launchIn(scope)