@@ -153,6 +153,7 @@ export interface LocalStore {
153
153
// change.
154
154
handleUserChange ( user : User ) : Promise < UserChangeResult > ;
155
155
156
+ /* Accept locally generated Mutations and commit them to storage. */
156
157
localWrite ( mutations : Mutation [ ] ) : Promise < LocalWriteResult > ;
157
158
158
159
/**
@@ -180,7 +181,9 @@ export interface LocalStore {
180
181
rejectBatch ( batchId : BatchId ) : Promise < MaybeDocumentMap > ;
181
182
182
183
/**
183
- * Returns the largest (latest) batch id in mutation queue that is pending server response.
184
+ * Returns the largest (latest) batch id in mutation queue that is pending
185
+ * server response.
186
+ *
184
187
* Returns `BATCHID_UNKNOWN` if the queue is empty.
185
188
*/
186
189
getHighestUnacknowledgedBatchId ( ) : Promise < BatchId > ;
@@ -270,9 +273,9 @@ export interface LocalStore {
270
273
* Implements `LocalStore` interface.
271
274
*
272
275
* Note: some field defined in this class might have public access level, but
273
- * the class is not exported so they are only accessible from this file. This is
274
- * useful to implement optional features (like bundles) in free functions, such
275
- * that they are tree-shakeable.
276
+ * the class is not exported so they are only accessible from this module.
277
+ * This is useful to implement optional features (like bundles) in free
278
+ * functions, such that they are tree-shakeable.
276
279
*/
277
280
class LocalStoreImpl implements LocalStore {
278
281
/**
@@ -347,19 +350,10 @@ class LocalStoreImpl implements LocalStore {
347
350
this . queryEngine . setLocalDocumentsView ( this . localDocuments ) ;
348
351
}
349
352
350
- /** Starts the LocalStore. */
351
353
start ( ) : Promise < void > {
352
354
return Promise . resolve ( ) ;
353
355
}
354
356
355
- /**
356
- * Tells the LocalStore that the currently authenticated user has changed.
357
- *
358
- * In response the local store switches the mutation queue to the new user and
359
- * returns any resulting document changes.
360
- */
361
- // PORTING NOTE: Android and iOS only return the documents affected by the
362
- // change.
363
357
async handleUserChange ( user : User ) : Promise < UserChangeResult > {
364
358
let newMutationQueue = this . mutationQueue ;
365
359
let newLocalDocuments = this . localDocuments ;
@@ -430,7 +424,6 @@ class LocalStoreImpl implements LocalStore {
430
424
return result ;
431
425
}
432
426
433
- /* Accept locally generated Mutations and commit them to storage. */
434
427
localWrite ( mutations : Mutation [ ] ) : Promise < LocalWriteResult > {
435
428
const localWriteTime = Timestamp . now ( ) ;
436
429
const keys = mutations . reduce (
@@ -488,20 +481,6 @@ class LocalStoreImpl implements LocalStore {
488
481
} ) ;
489
482
}
490
483
491
- /**
492
- * Acknowledge the given batch.
493
- *
494
- * On the happy path when a batch is acknowledged, the local store will
495
- *
496
- * + remove the batch from the mutation queue;
497
- * + apply the changes to the remote document cache;
498
- * + recalculate the latency compensated view implied by those changes (there
499
- * may be mutations in the queue that affect the documents but haven't been
500
- * acknowledged yet); and
501
- * + give the changed documents back the sync engine
502
- *
503
- * @returns The resulting (modified) documents.
504
- */
505
484
acknowledgeBatch (
506
485
batchResult : MutationBatchResult
507
486
) : Promise < MaybeDocumentMap > {
@@ -525,12 +504,6 @@ class LocalStoreImpl implements LocalStore {
525
504
) ;
526
505
}
527
506
528
- /**
529
- * Remove mutations from the MutationQueue for the specified batch;
530
- * LocalDocuments will be recalculated.
531
- *
532
- * @returns The resulting modified documents.
533
- */
534
507
rejectBatch ( batchId : BatchId ) : Promise < MaybeDocumentMap > {
535
508
return this . persistence . runTransaction (
536
509
'Reject batch' ,
@@ -554,10 +527,6 @@ class LocalStoreImpl implements LocalStore {
554
527
) ;
555
528
}
556
529
557
- /**
558
- * Returns the largest (latest) batch id in mutation queue that is pending server response.
559
- * Returns `BATCHID_UNKNOWN` if the queue is empty.
560
- */
561
530
getHighestUnacknowledgedBatchId ( ) : Promise < BatchId > {
562
531
return this . persistence . runTransaction (
563
532
'Get highest unacknowledged batch id' ,
@@ -568,10 +537,6 @@ class LocalStoreImpl implements LocalStore {
568
537
) ;
569
538
}
570
539
571
- /**
572
- * Returns the last consistent snapshot processed (used by the RemoteStore to
573
- * determine whether to buffer incoming snapshots from the backend).
574
- */
575
540
getLastRemoteSnapshotVersion ( ) : Promise < SnapshotVersion > {
576
541
return this . persistence . runTransaction (
577
542
'Get last remote snapshot version' ,
@@ -580,14 +545,6 @@ class LocalStoreImpl implements LocalStore {
580
545
) ;
581
546
}
582
547
583
- /**
584
- * Update the "ground-state" (remote) documents. We assume that the remote
585
- * event reflects any write batches that have been acknowledged or rejected
586
- * (i.e. we do not re-apply local mutations to updates from this event).
587
- *
588
- * LocalDocuments are re-calculated if there are remaining mutations in the
589
- * queue.
590
- */
591
548
applyRemoteEvent ( remoteEvent : RemoteEvent ) : Promise < MaybeDocumentMap > {
592
549
const remoteVersion = remoteEvent . snapshotVersion ;
593
550
let newTargetDataByTargetMap = this . targetDataByTarget ;
@@ -801,9 +758,6 @@ class LocalStoreImpl implements LocalStore {
801
758
return changes > 0 ;
802
759
}
803
760
804
- /**
805
- * Notify local store of the changed views to locally pin documents.
806
- */
807
761
async notifyLocalViewChanges ( viewChanges : LocalViewChanges [ ] ) : Promise < void > {
808
762
try {
809
763
await this . persistence . runTransaction (
@@ -871,12 +825,6 @@ class LocalStoreImpl implements LocalStore {
871
825
}
872
826
}
873
827
874
- /**
875
- * Gets the mutation batch after the passed in batchId in the mutation queue
876
- * or null if empty.
877
- * @param afterBatchId If provided, the batch to search after.
878
- * @returns The next mutation or null if there wasn't one.
879
- */
880
828
nextMutationBatch ( afterBatchId ?: BatchId ) : Promise < MutationBatch | null > {
881
829
return this . persistence . runTransaction (
882
830
'Get next mutation batch' ,
@@ -893,24 +841,12 @@ class LocalStoreImpl implements LocalStore {
893
841
) ;
894
842
}
895
843
896
- /**
897
- * Read the current value of a Document with a given key or null if not
898
- * found - used for testing.
899
- */
900
844
readDocument ( key : DocumentKey ) : Promise < MaybeDocument | null > {
901
845
return this . persistence . runTransaction ( 'read document' , 'readonly' , txn => {
902
846
return this . localDocuments . getDocument ( txn , key ) ;
903
847
} ) ;
904
848
}
905
849
906
- /**
907
- * Assigns the given target an internal ID so that its results can be pinned so
908
- * they don't get GC'd. A target must be allocated in the local store before
909
- * the store can be used to manage its view.
910
- *
911
- * Allocating an already allocated `Target` will return the existing `TargetData`
912
- * for that `Target`.
913
- */
914
850
allocateTarget ( target : Target ) : Promise < TargetData > {
915
851
return this . persistence
916
852
. runTransaction ( 'Allocate target' , 'readwrite' , txn => {
@@ -961,11 +897,6 @@ class LocalStoreImpl implements LocalStore {
961
897
} ) ;
962
898
}
963
899
964
- /**
965
- * Returns the TargetData as seen by the LocalStore, including updates that may
966
- * have not yet been persisted to the TargetCache.
967
- */
968
- // Visible for testing.
969
900
getTargetData (
970
901
transaction : PersistenceTransaction ,
971
902
target : Target
@@ -980,14 +911,6 @@ class LocalStoreImpl implements LocalStore {
980
911
}
981
912
}
982
913
983
- /**
984
- * Unpin all the documents associated with the given target. If
985
- * `keepPersistedTargetData` is set to false and Eager GC enabled, the method
986
- * directly removes the associated target data from the target cache.
987
- *
988
- * Releasing a non-existing `Target` is a no-op.
989
- */
990
- // PORTING NOTE: `keepPersistedTargetData` is multi-tab only.
991
914
releaseTarget (
992
915
targetId : number ,
993
916
keepPersistedTargetData : boolean
@@ -1016,14 +939,6 @@ class LocalStoreImpl implements LocalStore {
1016
939
} ) ;
1017
940
}
1018
941
1019
- /**
1020
- * Runs the specified query against the local store and returns the results,
1021
- * potentially taking advantage of query data from previous executions (such
1022
- * as the set of remote keys).
1023
- *
1024
- * @param usePreviousResults Whether results from previous executions can
1025
- * be used to optimize this query execution.
1026
- */
1027
942
executeQuery (
1028
943
query : Query ,
1029
944
usePreviousResults : boolean
@@ -1160,9 +1075,9 @@ export interface MultiTabLocalStore extends LocalStore {
1160
1075
* for MultiTabSyncEngine.
1161
1076
*
1162
1077
* Note: some field defined in this class might have public access level, but
1163
- * the class is not exported so they are only accessible from this file. This is
1164
- * useful to implement optional features (like bundles) in free functions, such
1165
- * that they are tree-shakeable.
1078
+ * the class is not exported so they are only accessible from this module.
1079
+ * This is useful to implement optional features (like bundles) in free
1080
+ * functions, such that they are tree-shakeable.
1166
1081
*/
1167
1082
// PORTING NOTE: Web only.
1168
1083
class MultiTabLocalStoreImpl extends LocalStoreImpl
@@ -1188,7 +1103,6 @@ class MultiTabLocalStoreImpl extends LocalStoreImpl
1188
1103
return this . synchronizeLastDocumentChangeReadTime ( ) ;
1189
1104
}
1190
1105
1191
- /** Returns the local view of the documents affected by a mutation batch. */
1192
1106
lookupMutationDocuments ( batchId : BatchId ) : Promise < MaybeDocumentMap | null > {
1193
1107
return this . persistence . runTransaction (
1194
1108
'Lookup mutation documents' ,
@@ -1240,12 +1154,6 @@ class MultiTabLocalStoreImpl extends LocalStoreImpl
1240
1154
}
1241
1155
}
1242
1156
1243
- /**
1244
- * Returns the set of documents that have been updated since the last call.
1245
- * If this is the first call, returns the set of changes since client
1246
- * initialization. Further invocations will return document changes since
1247
- * the point of rejection.
1248
- */
1249
1157
getNewDocumentChanges ( ) : Promise < MaybeDocumentMap > {
1250
1158
return this . persistence
1251
1159
. runTransaction ( 'Get new document changes' , 'readonly' , txn =>
@@ -1260,11 +1168,6 @@ class MultiTabLocalStoreImpl extends LocalStoreImpl
1260
1168
} ) ;
1261
1169
}
1262
1170
1263
- /**
1264
- * Reads the newest document change from persistence and forwards the internal
1265
- * synchronization marker so that calls to `getNewDocumentChanges()`
1266
- * only return changes that happened after client initialization.
1267
- */
1268
1171
async synchronizeLastDocumentChangeReadTime ( ) : Promise < void > {
1269
1172
this . lastDocumentChangeReadTime = await this . persistence . runTransaction (
1270
1173
'Synchronize last document change read time' ,
0 commit comments