@nextgis/geocoder 1.13.2 → 1.13.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.13.5; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.13.5; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -1958,6 +1958,7 @@ var NgwConnector$1 = /** @class */ (function () {
1958
1958
  this.id = ID++;
1959
1959
  this.emitter = new events.exports.EventEmitter();
1960
1960
  this.routeStr = '/api/component/pyramid/route';
1961
+ this.activeRequests = [];
1961
1962
  var exist = findConnector(options);
1962
1963
  if (exist) {
1963
1964
  return exist;
@@ -2043,6 +2044,7 @@ var NgwConnector$1 = /** @class */ (function () {
2043
2044
  * Disconnecting a user. Aborting all current requests
2044
2045
  */
2045
2046
  NgwConnector.prototype.logout = function () {
2047
+ this.abort();
2046
2048
  removeConnector(this);
2047
2049
  this.options.auth = undefined;
2048
2050
  this.user = undefined;
@@ -2095,6 +2097,17 @@ var NgwConnector$1 = /** @class */ (function () {
2095
2097
  }
2096
2098
  }
2097
2099
  };
2100
+ /** Stop all api requests */
2101
+ NgwConnector.prototype.abort = function () {
2102
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
2103
+ var req = _a[_i];
2104
+ req.cancel();
2105
+ }
2106
+ this.activeRequests = [];
2107
+ };
2108
+ NgwConnector.prototype.getActiveApiRequests = function () {
2109
+ return __spreadArray([], this.activeRequests, true);
2110
+ };
2098
2111
  /**
2099
2112
  * Send request to NGW api router.
2100
2113
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -2316,7 +2329,13 @@ var NgwConnector$1 = /** @class */ (function () {
2316
2329
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
2317
2330
  }
2318
2331
  loadData(url, resolve, options, reject, onCancel);
2319
- }).catch(function (httpError) {
2332
+ })
2333
+ .then(function (resp) {
2334
+ _this._cleanActiveRequests(request);
2335
+ return resp;
2336
+ })
2337
+ .catch(function (httpError) {
2338
+ _this._cleanActiveRequests(request);
2320
2339
  if (httpError instanceof CancelablePromise.CancelError) ;
2321
2340
  else {
2322
2341
  // @ts-ignore
@@ -2335,8 +2354,15 @@ var NgwConnector$1 = /** @class */ (function () {
2335
2354
  request.cancel();
2336
2355
  });
2337
2356
  }
2357
+ this.activeRequests.push(request);
2338
2358
  return request;
2339
2359
  };
2360
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
2361
+ var activeRequestIndex = this.activeRequests.indexOf(request);
2362
+ if (activeRequestIndex !== -1) {
2363
+ this.activeRequests.splice(activeRequestIndex, 1);
2364
+ }
2365
+ };
2340
2366
  NgwConnector.prototype._handleHttpError = function (er) {
2341
2367
  if (er) {
2342
2368
  if (er instanceof NgwError) {