From e6786d20dc70460ccca1e3431f0da2693c0e21ac Mon Sep 17 00:00:00 2001 From: Ajesh Date: Sat, 4 Mar 2023 07:05:09 +0530 Subject: [PATCH] Make bookkeeper optional (#529) Signed-off-by: Ajesh Co-authored-by: Ajesh --- .../store/store5/StoreBuilder.kt | 2 +- .../store/store5/impl/RealMutableStore.kt | 10 +++++----- .../store/store5/impl/RealStoreBuilder.kt | 2 +- .../store/store5/impl/extensions/store.kt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreBuilder.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreBuilder.kt index 2f2c763..da467d3 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreBuilder.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreBuilder.kt @@ -27,7 +27,7 @@ interface StoreBuilder { fun build( updater: Updater, - bookkeeper: Bookkeeper + bookkeeper: Bookkeeper? = null ): MutableStore /** diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealMutableStore.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealMutableStore.kt index 1494f05..8c1b714 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealMutableStore.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealMutableStore.kt @@ -30,7 +30,7 @@ import org.mobilenativefoundation.store.store5.internal.result.EagerConflictReso internal class RealMutableStore( private val delegate: RealStore, private val updater: Updater, - private val bookkeeper: Bookkeeper, + private val bookkeeper: Bookkeeper?, ) : MutableStore, Clear.Key by delegate, Clear.All by delegate { private val storeLock = Mutex() @@ -107,9 +107,9 @@ internal class RealMutableStore EagerConflictResolutionResult.Success.NoConflicts + latest == null || bookkeeper == null || conflictsMightExist(key).not() -> EagerConflictResolutionResult.Success.NoConflicts else -> { try { val updaterResult = updater.post(key, latest).also { updaterResult -> diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt index 71ad56c..e0cdbc8 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt @@ -70,7 +70,7 @@ internal class RealStoreBuilder build( updater: Updater, - bookkeeper: Bookkeeper + bookkeeper: Bookkeeper? ): MutableStore = build().asMutableStore( updater = updater, diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/extensions/store.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/extensions/store.kt index 097b95c..29f4198 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/extensions/store.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/extensions/store.kt @@ -38,7 +38,7 @@ suspend fun Store.fresh(key: Key) = @Suppress("UNCHECKED_CAST") fun Store.asMutableStore( updater: Updater, - bookkeeper: Bookkeeper + bookkeeper: Bookkeeper? ): MutableStore { val delegate = this as? RealStore ?: throw Exception("MutableStore requires Store to be built using StoreBuilder")