diff --git a/src/GeoJoinerOnSnapshot.ts b/src/GeoJoinerOnSnapshot.ts index a0c621d..109af44 100644 --- a/src/GeoJoinerOnSnapshot.ts +++ b/src/GeoJoinerOnSnapshot.ts @@ -129,9 +129,11 @@ export class GeoJoinerOnSnapshot { * @param index Index of query who's snapshot has been triggered. */ private _processSnapshot(snapshot: GeoFirestoreTypes.web.QuerySnapshot, index: number): void { + const docChanges = Array.isArray(snapshot.docChanges) ? + snapshot.docChanges as any as GeoFirestoreTypes.web.DocumentChange[]: snapshot.docChanges(); if (!this._firstRoundResolved) this._queriesResolved[index] = 1; - if (snapshot.docChanges().length) { // Snapshot has data, key during first snapshot - snapshot.docChanges().forEach(change => { + if (docChanges.length) { // Snapshot has data, key during first snapshot + docChanges.forEach((change) => { const distance = change.doc.data().l ? calculateDistance(this._queryCriteria.center, change.doc.data().l) : null; const id = change.doc.id; const fromMap = this._docs.get(id); diff --git a/src/GeoQuerySnapshot.ts b/src/GeoQuerySnapshot.ts index 3339c54..44c57f9 100644 --- a/src/GeoQuerySnapshot.ts +++ b/src/GeoQuerySnapshot.ts @@ -51,7 +51,9 @@ export class GeoQuerySnapshot { * @returns Array of DocumentChanges. */ public docChanges(): GeoFirestoreTypes.DocumentChange[] { - return (this._querySnapshot.docChanges() as GeoFirestoreTypes.web.DocumentChange[]) + const docChanges = Array.isArray(this._querySnapshot.docChanges) ? + this._querySnapshot.docChanges as any as GeoFirestoreTypes.web.DocumentChange[]: this._querySnapshot.docChanges(); + return (docChanges as GeoFirestoreTypes.web.DocumentChange[]) .map((change: GeoFirestoreTypes.web.DocumentChange) => { return { doc: generateGeoQueryDocumentSnapshot(change.doc, this._center),