-
Notifications
You must be signed in to change notification settings - Fork 926
[Feat] Firestore onSnapshot support for bundles for feature branch. #8896
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
[Feat] Firestore onSnapshot support for bundles for feature branch. #8896
Conversation
Vertex AI Mock Responses Check
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (92,564 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
|
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.
Looks good. I think the only thing that needs to be fixed is checking for unsubscribed before creating a snapshot listener for a DocumentReference
) => void, | ||
error: args[curArg++] as (error: FirestoreError) => void, | ||
complete: args[curArg++] as () => void | ||
}, |
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: it feels like you could reduce some duplicate code by creating these observer objects higher in the function. It may only reduce two calls to onSnapshot[Query|Document]SnapshotBundle
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.
Yeah, that's what I had originally but it ended up being more lines of code due to the type definiton and then configuring the object with optional parameters. I can revist it though, if you'd like.
Edit: revisited, and done!
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.
LGTM
* | ||
* @internal | ||
*/ | ||
function normalizeSnapshotJsonFields(snapshotJson: object): { |
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 might have used a type predicate for this. However, since you are also checking values, this implementation is also okay, IMO.
e34353d
into
ddb-firestore-result-serialization
Discussion
Pull request to add onSnapshot listeners support for bundles to the Firestore SSR serialization feature branch.
This change adds a series of onSnapshot overloads that match the existing onSnapshot variants (observer, individual callback functions, etc) but accepts a bundle instead of a QuerySnapshot or a DocumentSnapshot.
The toJSON methods of
QuerySnapshot
andDocumentSnapshot
have also been updated to explicitly name the fields in the object return type.Fixed an issue in the bundle builder where the bundleName for
DocumentSnapshots
didn't match theResourcePath
of the document, which is needed when reconstituting theDocumentReference
inonSnapshot
.Finally, I cleaned up the text wrapping for the
onSnapshot
reference doc comments so they take up fewer lines of source code.Testing
Added integration tests to ensure that
onSnapshot
functions invoked with a bundle properly callnext
with the snapshot data initially and when the document is updated in the service, anderror
if the bundle is invalid. Made tests that exercise the method signatures that take an Observer as well.API Changes
Numerous
onSnapshot
overloads that now accept a bundle a parameter. These will be part of a formal API proposal once the full feature branch implementation is closer to completion.