Skip to content

Commit 2d5812e

Browse files
Closing the write and the watch stream when idle
1 parent 27c5482 commit 2d5812e

File tree

10 files changed

+374
-159
lines changed

10 files changed

+374
-159
lines changed

packages/firestore/src/api/database.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export class Firestore implements firestore.Firestore, FirebaseService {
310310
PlatformSupport.getPlatform(),
311311
databaseInfo,
312312
this._config.credentials,
313-
new AsyncQueue()
313+
this.initializeAsyncQueue()
314314
);
315315
return this._firestoreClient.start(persistence);
316316
}
@@ -455,6 +455,11 @@ export class Firestore implements firestore.Firestore, FirebaseService {
455455
);
456456
}
457457
}
458+
459+
/** Creates a new AsyncQueue. Can be overwritten to provide a custom queue. */
460+
protected initializeAsyncQueue(): AsyncQueue {
461+
return new AsyncQueue();
462+
}
458463
}
459464

460465
/**

packages/firestore/src/local/local_store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ export class LocalStore {
582582

583583
/**
584584
* Gets the mutation batch after the passed in batchId in the mutation queue
585-
* or null if empty.
586-
* @param afterBatchId If provided, the batch to search after.
587-
* @returns The next mutation or null if there wasn't one.
585+
* or null if empty.
586+
* @param afterBatchId If provided, the batch to search after.
587+
* @returns The next mutation or null if there wasn't one.
588588
*/
589589
nextMutationBatch(afterBatchId?: BatchId): Promise<MutationBatch | null> {
590590
return this.persistence.runTransaction('Get next mutation batch', txn => {

0 commit comments

Comments
 (0)