Skip to content

Commit e34353d

Browse files
authored
[Feat] Firestore onSnapshot support for bundles for feature branch. (#8896)
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` and `DocumentSnapshot` 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 the `ResourcePath` of the document, which is needed when reconstituting the `DocumentReference` in `onSnapshot`. Finally, I cleaned up the text wrapping for the `onSnapshot` reference doc comments so they take up fewer lines of source code.
1 parent b85747b commit e34353d

File tree

6 files changed

+1156
-95
lines changed

6 files changed

+1156
-95
lines changed

common/api-review/firestore.api.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,46 @@ export function onSnapshot<AppModelType, DbModelType extends DocumentData>(query
461461
// @public
462462
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
463463

464+
// @public
465+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
466+
467+
// @public
468+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
469+
470+
// @public
471+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
472+
473+
// @public
474+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
475+
476+
// @public
477+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, observer: {
478+
next: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
479+
error?: (error: FirestoreError) => void;
480+
complete?: () => void;
481+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
482+
483+
// @public
484+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, observer: {
485+
next: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
486+
error?: (error: FirestoreError) => void;
487+
complete?: () => void;
488+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
489+
490+
// @public
491+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: {
492+
next: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
493+
error?: (error: FirestoreError) => void;
494+
complete?: () => void;
495+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
496+
497+
// @public
498+
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: {
499+
next: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
500+
error?: (error: FirestoreError) => void;
501+
complete?: () => void;
502+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
503+
464504
// @public
465505
export function onSnapshotsInSync(firestore: Firestore, observer: {
466506
next?: (value: void) => void;

0 commit comments

Comments
 (0)