@@ -22,7 +22,7 @@ internal final class InternalDefaultLiveMap: Sendable {
2222
2323 internal var testsOnly_objectID : String {
2424 mutex. withLock {
25- mutableState. liveObject . objectID
25+ mutableState. liveObjectMutableState . objectID
2626 }
2727 }
2828
@@ -34,13 +34,13 @@ internal final class InternalDefaultLiveMap: Sendable {
3434
3535 internal var testsOnly_siteTimeserials : [ String : String ] {
3636 mutex. withLock {
37- mutableState. liveObject . siteTimeserials
37+ mutableState. liveObjectMutableState . siteTimeserials
3838 }
3939 }
4040
4141 internal var testsOnly_createOperationIsMerged : Bool {
4242 mutex. withLock {
43- mutableState. liveObject . createOperationIsMerged
43+ mutableState. liveObjectMutableState . createOperationIsMerged
4444 }
4545 }
4646
@@ -76,7 +76,7 @@ internal final class InternalDefaultLiveMap: Sendable {
7676 userCallbackQueue: DispatchQueue ,
7777 clock: SimpleClock ,
7878 ) {
79- mutableState = . init( liveObject : . init( objectID: objectID) , data: data, semantics: semantics)
79+ mutableState = . init( liveObjectMutableState : . init( objectID: objectID) , data: data, semantics: semantics)
8080 self . logger = logger
8181 self . userCallbackQueue = userCallbackQueue
8282 self . clock = clock
@@ -201,21 +201,21 @@ internal final class InternalDefaultLiveMap: Sendable {
201201 internal func subscribe( listener: @escaping LiveObjectUpdateCallback < DefaultLiveMapUpdate > , coreSDK: CoreSDK ) throws ( ARTErrorInfo) -> any SubscribeResponse {
202202 try mutex. ablyLiveObjects_withLockWithTypedThrow { ( ) throws ( ARTErrorInfo) in
203203 // swiftlint:disable:next trailing_closure
204- try mutableState. liveObject . subscribe ( listener: listener, coreSDK: coreSDK, updateSelfLater: { [ weak self] action in
204+ try mutableState. liveObjectMutableState . subscribe ( listener: listener, coreSDK: coreSDK, updateSelfLater: { [ weak self] action in
205205 guard let self else {
206206 return
207207 }
208208
209209 mutex. withLock {
210- action ( & mutableState. liveObject )
210+ action ( & mutableState. liveObjectMutableState )
211211 }
212212 } )
213213 }
214214 }
215215
216216 internal func unsubscribeAll( ) {
217217 mutex. withLock {
218- mutableState. liveObject . unsubscribeAll ( )
218+ mutableState. liveObjectMutableState . unsubscribeAll ( )
219219 }
220220 }
221221
@@ -235,7 +235,7 @@ internal final class InternalDefaultLiveMap: Sendable {
235235 /// This is used to instruct this map to emit updates during an `OBJECT_SYNC`.
236236 internal func emit( _ update: LiveObjectUpdate < DefaultLiveMapUpdate > ) {
237237 mutex. withLock {
238- mutableState. liveObject . emit ( update, on: userCallbackQueue)
238+ mutableState. liveObjectMutableState . emit ( update, on: userCallbackQueue)
239239 }
240240 }
241241
@@ -346,9 +346,9 @@ internal final class InternalDefaultLiveMap: Sendable {
346346
347347 // MARK: - Mutable state and the operations that affect it
348348
349- private struct MutableState {
349+ private struct MutableState : InternalLiveObject {
350350 /// The mutable state common to all LiveObjects.
351- internal var liveObject : LiveObjectMutableState < DefaultLiveMapUpdate >
351+ internal var liveObjectMutableState : LiveObjectMutableState < DefaultLiveMapUpdate >
352352
353353 /// The internal data that this map holds, per RTLM3.
354354 internal var data : [ String : InternalObjectsMapEntry ]
@@ -368,10 +368,10 @@ internal final class InternalDefaultLiveMap: Sendable {
368368 userCallbackQueue: DispatchQueue ,
369369 ) -> LiveObjectUpdate < DefaultLiveMapUpdate > {
370370 // RTLM6a: Replace the private siteTimeserials with the value from ObjectState.siteTimeserials
371- liveObject . siteTimeserials = state. siteTimeserials
371+ liveObjectMutableState . siteTimeserials = state. siteTimeserials
372372
373373 // RTLM6b: Set the private flag createOperationIsMerged to false
374- liveObject . createOperationIsMerged = false
374+ liveObjectMutableState . createOperationIsMerged = false
375375
376376 // RTLM6c: Set data to ObjectState.map.entries, or to an empty map if it does not exist
377377 data = state. map? . entries? . mapValues { . init( objectsMapEntry: $0) } ?? [ : ]
@@ -428,7 +428,7 @@ internal final class InternalDefaultLiveMap: Sendable {
428428 }
429429
430430 // RTLM17b: Set the private flag createOperationIsMerged to true
431- liveObject . createOperationIsMerged = true
431+ liveObjectMutableState . createOperationIsMerged = true
432432
433433 // RTLM17c: Merge the updates, skipping no-ops
434434 // I don't love having to use uniqueKeysWithValues, when I shouldn't have to. I should be able to reason _statically_ that there are no overlapping keys. The problem that we're trying to use LiveMapUpdate throughout instead of something more communicative. But I don't know what's to come in the spec so I don't want to mess with this internal interface.
@@ -457,14 +457,14 @@ internal final class InternalDefaultLiveMap: Sendable {
457457 userCallbackQueue: DispatchQueue ,
458458 clock: SimpleClock ,
459459 ) {
460- guard let applicableOperation = liveObject . canApplyOperation ( objectMessageSerial: objectMessageSerial, objectMessageSiteCode: objectMessageSiteCode, logger: logger) else {
460+ guard let applicableOperation = liveObjectMutableState . canApplyOperation ( objectMessageSerial: objectMessageSerial, objectMessageSiteCode: objectMessageSiteCode, logger: logger) else {
461461 // RTLM15b
462462 logger. log ( " Operation \( operation) (serial: \( String ( describing: objectMessageSerial) ) , siteCode: \( String ( describing: objectMessageSiteCode) ) ) should not be applied; discarding " , level: . debug)
463463 return
464464 }
465465
466466 // RTLM15c
467- liveObject . siteTimeserials [ applicableOperation. objectMessageSiteCode] = applicableOperation. objectMessageSerial
467+ liveObjectMutableState . siteTimeserials [ applicableOperation. objectMessageSiteCode] = applicableOperation. objectMessageSerial
468468
469469 switch operation. action {
470470 case . known( . mapCreate) :
@@ -477,7 +477,7 @@ internal final class InternalDefaultLiveMap: Sendable {
477477 clock: clock,
478478 )
479479 // RTLM15d1a
480- liveObject . emit ( update, on: userCallbackQueue)
480+ liveObjectMutableState . emit ( update, on: userCallbackQueue)
481481 case . known( . mapSet) :
482482 guard let mapOp = operation. mapOp else {
483483 logger. log ( " Could not apply MAP_SET since operation.mapOp is missing " , level: . warn)
@@ -499,7 +499,7 @@ internal final class InternalDefaultLiveMap: Sendable {
499499 clock: clock,
500500 )
501501 // RTLM15d2a
502- liveObject . emit ( update, on: userCallbackQueue)
502+ liveObjectMutableState . emit ( update, on: userCallbackQueue)
503503 case . known( . mapRemove) :
504504 guard let mapOp = operation. mapOp else {
505505 return
@@ -511,7 +511,7 @@ internal final class InternalDefaultLiveMap: Sendable {
511511 operationTimeserial: applicableOperation. objectMessageSerial,
512512 )
513513 // RTLM15d3a
514- liveObject . emit ( update, on: userCallbackQueue)
514+ liveObjectMutableState . emit ( update, on: userCallbackQueue)
515515 default :
516516 // RTLM15d4
517517 logger. log ( " Operation \( operation) has unsupported action for LiveMap; discarding " , level: . warn)
@@ -637,7 +637,7 @@ internal final class InternalDefaultLiveMap: Sendable {
637637 userCallbackQueue: DispatchQueue ,
638638 clock: SimpleClock ,
639639 ) -> LiveObjectUpdate < DefaultLiveMapUpdate > {
640- if liveObject . createOperationIsMerged {
640+ if liveObjectMutableState . createOperationIsMerged {
641641 // RTLM16b
642642 logger. log ( " Not applying MAP_CREATE because a MAP_CREATE has already been applied " , level: . warn)
643643 return . noop
@@ -663,7 +663,7 @@ internal final class InternalDefaultLiveMap: Sendable {
663663
664664 // RTO4b2a
665665 let mapUpdate = DefaultLiveMapUpdate ( update: previousData. mapValues { _ in . removed } )
666- liveObject . emit ( . update( mapUpdate) , on: userCallbackQueue)
666+ liveObjectMutableState . emit ( . update( mapUpdate) , on: userCallbackQueue)
667667 }
668668 }
669669
0 commit comments