diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e04f00045..dc1baf3979a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## 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 * `MimeeTypes>`: diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt index 6a62cf5bdfa..3abd96bc9b5 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt @@ -48,6 +48,14 @@ data class PaginationResult( } fun emptyPaginationResult() = PaginationResult(0, 0, emptyList(), 0L) +fun emptyPaginationResult( + basePagination: Pagination +) = PaginationResult( + basePagination.page, + basePagination.size, + emptyList(), + 0L +) /** * @return New [PaginationResult] with [data] without checking of data sizes equality diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt index 28ab069b0ff..413e116cd92 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt @@ -33,6 +33,14 @@ open class WriteCRUDCacheRepo( override val updatedObjectsFlow: Flow by parentRepo::updatedObjectsFlow override val deletedObjectsIdsFlow: Flow 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 { kvCache.unset(it) }.launchIn(scope)