Skip to content

Commit

Permalink
Fixed bug in updateCriteria() after query is cancelled (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Wenger committed Oct 14, 2016
1 parent 7ef8c5c commit a51048e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/geoQuery.js
Expand Up @@ -371,6 +371,12 @@ var GeoQuery = function (firebaseRef, queryCriteria) {
for (var i = 0; i < numKeys; ++i) {
var key = keys[i];

// If the query was cancelled while going through this loop, stop updating locations and stop
// firing events
if (_cancelled === true) {
break;
}

// Get the cached information for this location
var locationDict = _locationsTracked[key];

Expand Down Expand Up @@ -473,6 +479,9 @@ var GeoQuery = function (firebaseRef, queryCriteria) {
* query via on() will be cancelled. This query can no longer be used in the future.
*/
this.cancel = function () {
// Mark this query as cancelled
_cancelled = true;

// Cancel all callbacks in this query's callback list
_callbacks = {
ready: [],
Expand Down Expand Up @@ -516,6 +525,9 @@ var GeoQuery = function (firebaseRef, queryCriteria) {
key_moved: []
};

// Variable to track when the query is cancelled
var _cancelled = false;

// Variables used to keep track of when to fire the "ready" event
var _valueEventFired = false;
var _outstandingGeohashReadyEvents;
Expand Down

0 comments on commit a51048e

Please sign in to comment.