@@ -31,7 +31,7 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
3131 private val delegate : RealStore <Key , Network , Output , Local >,
3232 private val updater : Updater <Key , Output , * >,
3333 private val bookkeeper : Bookkeeper <Key >? ,
34- private val logger : Logger = DefaultLogger ()
34+ private val logger : Logger = DefaultLogger (),
3535) : MutableStore<Key, Output>, Clear.Key<Key> by delegate, Clear.All by delegate {
3636 private val storeLock = Mutex ()
3737 private val keyToWriteRequestQueue = mutableMapOf<Key , WriteRequestQueue <Key , Output , * >>()
@@ -42,7 +42,6 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
4242 safeInitStore(request.key)
4343
4444 when (val eagerConflictResolutionResult = tryEagerlyResolveConflicts<Response >(request.key)) {
45-
4645 // TODO(matt-ramotar): Many use cases will not want to pull immediately after failing
4746 // to push local changes. We should enable configuration of conflict resolution strategies,
4847 // such as logging, retrying, canceling.
@@ -56,10 +55,11 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
5655 }
5756
5857 is EagerConflictResolutionResult .Success .ConflictsResolved -> {
59- val message = when (val result = eagerConflictResolutionResult.value) {
60- is UpdaterResult .Success .Typed <* > -> result.value.toString()
61- is UpdaterResult .Success .Untyped -> result.value.toString()
62- }
58+ val message =
59+ when (val result = eagerConflictResolutionResult.value) {
60+ is UpdaterResult .Success .Typed <* > -> result.value.toString()
61+ is UpdaterResult .Success .Untyped -> result.value.toString()
62+ }
6363 logger.debug(message)
6464 }
6565
@@ -230,18 +230,17 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
230230
231231 @AnyThread
232232 private suspend fun <Response : Any > tryEagerlyResolveConflicts (key : Key ): EagerConflictResolutionResult <Response > {
233-
234- val (latest, conflictsExist) = withThreadSafety(key) {
235- val latest = delegate.latestOrNull(key)
236- val conflictsExist = latest != null && bookkeeper != null && conflictsMightExist(key)
237- latest to conflictsExist
238- }
233+ val (latest, conflictsExist) =
234+ withThreadSafety(key) {
235+ val latest = delegate.latestOrNull(key)
236+ val conflictsExist = latest != null && bookkeeper != null && conflictsMightExist(key)
237+ latest to conflictsExist
238+ }
239239
240240 if (! conflictsExist || latest == null ) {
241241 return EagerConflictResolutionResult .Success .NoConflicts
242242 }
243243
244-
245244 return try {
246245 val updaterResult =
247246 updater.post(key, latest).also { updaterResult ->
@@ -266,7 +265,7 @@ internal class RealMutableStore<Key : Any, Network : Any, Output : Any, Local :
266265 if (keyToThreadSafety[key] == null ) {
267266 keyToThreadSafety[key] = ThreadSafety ()
268267 }
269- if (keyToWriteRequestQueue[key] == null ) {
268+ if (keyToWriteRequestQueue[key] == null ) {
270269 keyToWriteRequestQueue[key] = ArrayDeque ()
271270 }
272271 }
0 commit comments