You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Applies a `MAP_SET` operation to a key, per RTLM7.
248
261
///
249
262
/// This is currently exposed just so that the tests can test RTLM7 without having to go through a convoluted replaceData(…) call, but I _think_ that it's going to be used in further contexts when we introduce the handling of incoming object operations in a future spec PR.
@@ -310,36 +323,53 @@ internal final class DefaultLiveMap: LiveMap {
310
323
// RTLM6c: Set data to ObjectState.map.entries, or to an empty map if it does not exist
311
324
data = state.map?.entries ??[:]
312
325
313
-
// RTLM6d: If ObjectState.createOp is present
326
+
// RTLM6d: If ObjectState.createOp is present, merge the initial value into the LiveMap as described in RTLM17
314
327
iflet createOp = state.createOp {
315
-
// RTLM6d1: For each key–ObjectsMapEntry pair in ObjectState.createOp.map.entries
316
-
iflet entries = createOp.map?.entries {
317
-
for(key, entry)in entries {
318
-
if entry.tombstone ==true{
319
-
// RTLM6d1b: If ObjectsMapEntry.tombstone is true, apply the MAP_REMOVE operation
320
-
// to the specified key using ObjectsMapEntry.timeserial per RTLM8
321
-
applyMapRemoveOperation(
322
-
key: key,
323
-
operationTimeserial: entry.timeserial,
324
-
)
325
-
}else{
326
-
// RTLM6d1a: If ObjectsMapEntry.tombstone is false, apply the MAP_SET operation
327
-
// to the specified key using ObjectsMapEntry.timeserial and ObjectsMapEntry.data per RTLM7
328
-
applyMapSetOperation(
329
-
key: key,
330
-
operationTimeserial: entry.timeserial,
331
-
operationData: entry.data,
332
-
objectsPool:&objectsPool,
333
-
mapDelegate: mapDelegate,
334
-
coreSDK: coreSDK,
335
-
logger: logger,
336
-
)
337
-
}
328
+
mergeInitialValue(
329
+
from: createOp,
330
+
objectsPool:&objectsPool,
331
+
mapDelegate: mapDelegate,
332
+
coreSDK: coreSDK,
333
+
logger: logger,
334
+
)
335
+
}
336
+
}
337
+
338
+
/// Merges the initial value from an ObjectOperation into this LiveMap, per RTLM17.
339
+
internalmutatingfunc mergeInitialValue(
340
+
from operation:ObjectOperation,
341
+
objectsPool:inoutObjectsPool,
342
+
mapDelegate:LiveMapObjectPoolDelegate?,
343
+
coreSDK:CoreSDK,
344
+
logger:AblyPlugin.Logger,
345
+
){
346
+
// RTLM17a: For each key–ObjectsMapEntry pair in ObjectOperation.map.entries
347
+
iflet entries = operation.map?.entries {
348
+
for(key, entry)in entries {
349
+
if entry.tombstone ==true{
350
+
// RTLM17a2: If ObjectsMapEntry.tombstone is true, apply the MAP_REMOVE operation
351
+
// as described in RTLM8, passing in the current key as ObjectsMapOp, and ObjectsMapEntry.timeserial as the operation's serial
352
+
applyMapRemoveOperation(
353
+
key: key,
354
+
operationTimeserial: entry.timeserial,
355
+
)
356
+
}else{
357
+
// RTLM17a1: If ObjectsMapEntry.tombstone is false, apply the MAP_SET operation
358
+
// as described in RTLM7, passing in ObjectsMapEntry.data and the current key as ObjectsMapOp, and ObjectsMapEntry.timeserial as the operation's serial
359
+
applyMapSetOperation(
360
+
key: key,
361
+
operationTimeserial: entry.timeserial,
362
+
operationData: entry.data,
363
+
objectsPool:&objectsPool,
364
+
mapDelegate: mapDelegate,
365
+
coreSDK: coreSDK,
366
+
logger: logger,
367
+
)
338
368
}
339
369
}
340
-
// RTLM6d2: Set the private flag createOperationIsMerged to true
341
-
liveObject.createOperationIsMerged =true
342
370
}
371
+
// RTLM17b: Set the private flag createOperationIsMerged to true
372
+
liveObject.createOperationIsMerged =true
343
373
}
344
374
345
375
/// Applies a `MAP_SET` operation to a key, per RTLM7.
0 commit comments