-
Notifications
You must be signed in to change notification settings - Fork 927
Remove MultiTabLocalStore #3436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
💥 No ChangesetLatest commit: 08f927a Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
41ea951
to
a857f59
Compare
@@ -202,7 +202,8 @@ export class FirestoreClient { | |||
enableNetwork(): Promise<void> { | |||
this.verifyNotTerminated(); | |||
return this.asyncQueue.enqueue(() => { | |||
return this.syncEngine.enableNetwork(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the FirestoreClient -> SyncEngine -> LocalStore -> Persistence indirection for enableNetwork
and disableNetwork
since I didn't want to come up with non-conflicting global names for the new free-standing functions.
Binary Size ReportAffected SDKs
Test Logs |
const mutationQueueImpl = debugCast( | ||
localStoreImpl.mutationQueue, | ||
IndexedDbMutationQueue // We only support IndexedDb in multi-tab mode. | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setup is being done in every reworked method, would it be possible to refactor it out into a helper function returning two values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not that pretty since it needs a cast in the method call, but I changed it:
const [localStoreImpl, mutationQueueImpl] =
debugCast(localStore, LocalStoreImpl, (localStoreImpl as LocalStoreImpl).mutationQueue, IndexedDbMutationQueue);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I undid this since this pattern actually uses one more line for each invocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what I had in mind was just
const [localStoreImpl, mutationQueueImpl] = foo(localStore);
with the helper function taking care of everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a multiTabLocalStore
function that returns LocalStoreImpl, IndexedDbRemoteDocumentCache, IndexedDbMutationQueue and IndexedDbTargetCache. Does that sound good to you?
* Returns the set of documents that have been updated since the last call. | ||
* If this is the first call, returns the set of changes since client | ||
* initialization. Further invocations will return document changes since | ||
* the point of rejection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what is meant by rejection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to will return document that have changed since the prior call
.
async synchronizeLastDocumentChangeReadTime(): Promise<void> { | ||
this.lastDocumentChangeReadTime = await this.persistence.runTransaction( | ||
/** | ||
* Reads the newest document change from persistence and forwards the internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can you clarify where/to what it's being forwarded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "forward" does not mean "send something along" but rather "move forward". Rewritten.
This PR is part of my effort to create a cache-only entry point into Firestore (for
getDocFromLocalCache()
). My plan is to split up the component providers and extract one that only providesPersistence
,SharedClientState
andLocalStore
. The "WIP end result" is here: #3425. This PR is a version of the first commit in that PR.To avoid the combinatorial explosion of
ComponentProvider
s, this PR removesMultiTabLocalStore
and instead makes all methods inMultiTabLocalStore
tree-shakeable.