@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
  import CancelablePromise from '@nextgis/cancelable-promise';
3
3
  import { objectAssign, fixUrlStr } from '@nextgis/utils';
4
4
  import NgwConnector from '@nextgis/ngw-connector';
@@ -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
  var Geocoder = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1961,6 +1961,7 @@ var Geocoder = (function (exports) {
1961
1961
  this.id = ID++;
1962
1962
  this.emitter = new events.exports.EventEmitter();
1963
1963
  this.routeStr = '/api/component/pyramid/route';
1964
+ this.activeRequests = [];
1964
1965
  var exist = findConnector(options);
1965
1966
  if (exist) {
1966
1967
  return exist;
@@ -2046,6 +2047,7 @@ var Geocoder = (function (exports) {
2046
2047
  * Disconnecting a user. Aborting all current requests
2047
2048
  */
2048
2049
  NgwConnector.prototype.logout = function () {
2050
+ this.abort();
2049
2051
  removeConnector(this);
2050
2052
  this.options.auth = undefined;
2051
2053
  this.user = undefined;
@@ -2098,6 +2100,17 @@ var Geocoder = (function (exports) {
2098
2100
  }
2099
2101
  }
2100
2102
  };
2103
+ /** Stop all api requests */
2104
+ NgwConnector.prototype.abort = function () {
2105
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
2106
+ var req = _a[_i];
2107
+ req.cancel();
2108
+ }
2109
+ this.activeRequests = [];
2110
+ };
2111
+ NgwConnector.prototype.getActiveApiRequests = function () {
2112
+ return __spreadArray([], this.activeRequests, true);
2113
+ };
2101
2114
  /**
2102
2115
  * Send request to NGW api router.
2103
2116
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -2319,7 +2332,13 @@ var Geocoder = (function (exports) {
2319
2332
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
2320
2333
  }
2321
2334
  loadData(url, resolve, options, reject, onCancel);
2322
- }).catch(function (httpError) {
2335
+ })
2336
+ .then(function (resp) {
2337
+ _this._cleanActiveRequests(request);
2338
+ return resp;
2339
+ })
2340
+ .catch(function (httpError) {
2341
+ _this._cleanActiveRequests(request);
2323
2342
  if (httpError instanceof CancelablePromise.CancelError) ;
2324
2343
  else {
2325
2344
  // @ts-ignore
@@ -2338,8 +2357,15 @@ var Geocoder = (function (exports) {
2338
2357
  request.cancel();
2339
2358
  });
2340
2359
  }
2360
+ this.activeRequests.push(request);
2341
2361
  return request;
2342
2362
  };
2363
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
2364
+ var activeRequestIndex = this.activeRequests.indexOf(request);
2365
+ if (activeRequestIndex !== -1) {
2366
+ this.activeRequests.splice(activeRequestIndex, 1);
2367
+ }
2368
+ };
2343
2369
  NgwConnector.prototype._handleHttpError = function (er) {
2344
2370
  if (er) {
2345
2371
  if (er instanceof NgwError) {