geofirex icon indicating copy to clipboard operation
geofirex copied to clipboard

Correct way to unsubscribe from a current geoquery?

Open jackie-d opened this issue 4 years ago • 0 comments

Hi, I found that calling multiple times

const subscription = this.geo.query<any>(ref).within(center, radius, 'position', { log: true })

instances multiple listeners, even if a call to .unsubscribe is made. Each time I leave a page and re-enter on it, a new listener is added, resulting in multiple query launched (visible from the console log).

ionViewDidEnter() {
    this.subscription = this.geo.query<any>(ref).within(center, radius, 'position', { log: true });
}

ionViewDidLeave() {
   this.subscription.unsubscribe();
}
index.esm.js:1475 GeoFireX Query
index.esm.js:1476 🌐 Center 03.7550653,01.2864031. Radius 1
index.esm.js:1477 📍 Hits: 1
index.esm.js:1478 ⌚ Elapsed time: 3255ms
index.esm.js:1479 🟢 Within Radius: 1

index.esm.js:1475 GeoFireX Query
index.esm.js:1476 🌐 Center 03.7550653,01.2864031. Radius 1
index.esm.js:1477 📍 Hits: 1
index.esm.js:1478 ⌚ Elapsed time: 3513ms
index.esm.js:1479 🟢 Within Radius: 1

Am I missing something or is this a known issue?

PS: The code provided is an exemplification, as I'm using it on a combineLatest structure and obviously using a subscribe() on the result.

jackie-d avatar Apr 15 '20 08:04 jackie-d