mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-25 19:48:45 +00:00
remove usage of cache updates flows in autorecached repos
This commit is contained in:
parent
5f231c2212
commit
46c1887cbe
@ -21,9 +21,9 @@ open class AutoRecacheWriteCRUDRepo<RegisteredObject, Id, InputObject>(
|
|||||||
protected val idGetter: (RegisteredObject) -> Id
|
protected val idGetter: (RegisteredObject) -> Id
|
||||||
) : WriteCRUDRepo<RegisteredObject, Id, InputObject>, FallbackCacheRepo {
|
) : WriteCRUDRepo<RegisteredObject, Id, InputObject>, FallbackCacheRepo {
|
||||||
override val deletedObjectsIdsFlow: Flow<Id>
|
override val deletedObjectsIdsFlow: Flow<Id>
|
||||||
get() = (originalRepo.deletedObjectsIdsFlow + kvCache.onValueRemoved).distinctUntilChanged()
|
get() = (originalRepo.deletedObjectsIdsFlow).distinctUntilChanged()
|
||||||
override val newObjectsFlow: Flow<RegisteredObject>
|
override val newObjectsFlow: Flow<RegisteredObject>
|
||||||
get() = (originalRepo.newObjectsFlow + kvCache.onNewValue.map { it.second }).distinctUntilChanged()
|
get() = (originalRepo.newObjectsFlow).distinctUntilChanged()
|
||||||
override val updatedObjectsFlow: Flow<RegisteredObject>
|
override val updatedObjectsFlow: Flow<RegisteredObject>
|
||||||
get() = originalRepo.updatedObjectsFlow
|
get() = originalRepo.updatedObjectsFlow
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ open class AutoRecacheWriteKeyValueRepo<Id, RegisteredObject>(
|
|||||||
protected val kvCache: FullKVCache<Id, RegisteredObject> = FullKVCache()
|
protected val kvCache: FullKVCache<Id, RegisteredObject> = FullKVCache()
|
||||||
) : WriteKeyValueRepo<Id, RegisteredObject>, FallbackCacheRepo {
|
) : WriteKeyValueRepo<Id, RegisteredObject>, FallbackCacheRepo {
|
||||||
override val onValueRemoved: Flow<Id>
|
override val onValueRemoved: Flow<Id>
|
||||||
get() = (originalRepo.onValueRemoved + kvCache.onValueRemoved).distinctUntilChanged()
|
get() = (originalRepo.onValueRemoved).distinctUntilChanged()
|
||||||
|
|
||||||
override val onNewValue: Flow<Pair<Id, RegisteredObject>>
|
override val onNewValue: Flow<Pair<Id, RegisteredObject>>
|
||||||
get() = (originalRepo.onNewValue + kvCache.onNewValue).distinctUntilChanged()
|
get() = (originalRepo.onNewValue).distinctUntilChanged()
|
||||||
|
|
||||||
private val onRemovingUpdatesListeningJob = originalRepo.onValueRemoved.subscribeSafelyWithoutExceptions(scope) {
|
private val onRemovingUpdatesListeningJob = originalRepo.onValueRemoved.subscribeSafelyWithoutExceptions(scope) {
|
||||||
kvCache.unset(it)
|
kvCache.unset(it)
|
||||||
|
@ -25,7 +25,7 @@ open class AutoRecacheWriteKeyValuesRepo<Id, RegisteredObject>(
|
|||||||
override val onNewValue: Flow<Pair<Id, RegisteredObject>>
|
override val onNewValue: Flow<Pair<Id, RegisteredObject>>
|
||||||
get() = originalRepo.onNewValue
|
get() = originalRepo.onNewValue
|
||||||
override val onDataCleared: Flow<Id>
|
override val onDataCleared: Flow<Id>
|
||||||
get() = (originalRepo.onDataCleared + kvCache.onValueRemoved).distinctUntilChanged()
|
get() = (originalRepo.onDataCleared).distinctUntilChanged()
|
||||||
|
|
||||||
private val onDataClearedListeningJob = originalRepo.onDataCleared.subscribeSafelyWithoutExceptions(scope) {
|
private val onDataClearedListeningJob = originalRepo.onDataCleared.subscribeSafelyWithoutExceptions(scope) {
|
||||||
kvCache.unset(it)
|
kvCache.unset(it)
|
||||||
|
Loading…
Reference in New Issue
Block a user