@rdlabo/ionic-angular-kit 21.5.15 → 21.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -529,6 +529,34 @@ The write lifecycle is: update the replica immediately → append an outbox comm
|
|
|
529
529
|
the optimistic value → replay in the background → validate the server revision → store the confirmed value and
|
|
530
530
|
revision. The server remains authoritative; SQLite is the durable local working database, not an HTTP response cache.
|
|
531
531
|
|
|
532
|
+
When an API response is assembled from a base replica row plus product-owned local-only view rows, use
|
|
533
|
+
`enqueuePrepared()`. Its callback runs inside the shared replica mutation lane, so every read used to derive the
|
|
534
|
+
optimistic projection happens after earlier enqueue/ACK/pull applies. The base optimistic row, companion rows, and
|
|
535
|
+
Outbox command are then committed by one `transactReplica()` call. Preparation failure, invalid cross-scope rows,
|
|
536
|
+
duplicate row keys, non-JSON values, or an attempt to mutate commands/cursors leaves durable state unchanged.
|
|
537
|
+
|
|
538
|
+
```ts
|
|
539
|
+
await offlineSync.enqueuePrepared(async (repository) => {
|
|
540
|
+
const view = await readProductView(repository, scope, row);
|
|
541
|
+
return {
|
|
542
|
+
request: {
|
|
543
|
+
scopeId: scope.scopeId,
|
|
544
|
+
aggregateType: 'items',
|
|
545
|
+
identity: { kind: 'generated', localId: row.identity.localId },
|
|
546
|
+
operation: 'items.rename',
|
|
547
|
+
payload: { title },
|
|
548
|
+
optimisticValue: { ...row.values, title },
|
|
549
|
+
},
|
|
550
|
+
replicaTransaction: { putRows: [buildProductViewRow(scope, { ...view, title })] },
|
|
551
|
+
};
|
|
552
|
+
});
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Product-specific pullers that materialize their own aggregate tables must keep HTTP transport outside
|
|
556
|
+
`OfflineReplicaMutationCoordinator.run()` and wrap only the response apply read/derive/write section. This shares the
|
|
557
|
+
same short local critical section as enqueue, ACK, discard, and the generic pull service without holding a lock during
|
|
558
|
+
network latency.
|
|
559
|
+
|
|
532
560
|
For a DB row whose deletion is represented by absence, enqueue the same full row values with
|
|
533
561
|
`replicaMutation: 'delete'`. The runtime stores a library-owned durable tombstone: normal `getReplicaRow()` and
|
|
534
562
|
`getReplicaRows()` reads stop returning the row immediately, while synchronization retains its immutable generated
|