From 20e61ac46fecb63ab04a125f6caa0b30daf11d04 Mon Sep 17 00:00:00 2001 From: Tobias Gassmann Date: Sat, 26 Oct 2024 16:40:22 +0200 Subject: [PATCH 1/2] wrap call to off(firebaseQuery, 'value', valueUnsubscribe) in a setTimeout-0 --- packages/geofire/src/GeoQuery.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/geofire/src/GeoQuery.ts b/packages/geofire/src/GeoQuery.ts index eb75889..2c07838 100644 --- a/packages/geofire/src/GeoQuery.ts +++ b/packages/geofire/src/GeoQuery.ts @@ -478,8 +478,10 @@ export class GeoQuery { // and, if so, mark the value event as fired. // Note that Firebase fires the 'value' event after every 'child_added' event fires. const valueUnsubscribe = onValue(firebaseQuery, () => { - off(firebaseQuery, 'value', valueUnsubscribe); - this._geohashQueryReadyCallback(toQueryStr); + setTimeout(() => { + off(firebaseQuery, 'value', valueUnsubscribe); + this._geohashQueryReadyCallback(toQueryStr); + }, 0); }); // Add the geohash query to the current geohashes queried dictionary and save its state From 3f549510338bd8c2cbeb552b060b5e08dd8de225 Mon Sep 17 00:00:00 2001 From: Tobias Gassmann Date: Sat, 26 Oct 2024 17:53:47 +0200 Subject: [PATCH 2/2] use the unsubscribe function correctly --- packages/geofire/src/GeoQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/geofire/src/GeoQuery.ts b/packages/geofire/src/GeoQuery.ts index 2c07838..bf3a634 100644 --- a/packages/geofire/src/GeoQuery.ts +++ b/packages/geofire/src/GeoQuery.ts @@ -479,7 +479,7 @@ export class GeoQuery { // Note that Firebase fires the 'value' event after every 'child_added' event fires. const valueUnsubscribe = onValue(firebaseQuery, () => { setTimeout(() => { - off(firebaseQuery, 'value', valueUnsubscribe); + valueUnsubscribe(); this._geohashQueryReadyCallback(toQueryStr); }, 0); });