@nextgis/ngw-map 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/ngw-map; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; 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/ngw-map; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.13.5; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -4631,6 +4631,7 @@ var NgwConnector$1 = /** @class */ (function () {
4631
4631
  this.id = ID$1++;
4632
4632
  this.emitter = new events.exports.EventEmitter();
4633
4633
  this.routeStr = '/api/component/pyramid/route';
4634
+ this.activeRequests = [];
4634
4635
  var exist = findConnector(options);
4635
4636
  if (exist) {
4636
4637
  return exist;
@@ -4716,6 +4717,7 @@ var NgwConnector$1 = /** @class */ (function () {
4716
4717
  * Disconnecting a user. Aborting all current requests
4717
4718
  */
4718
4719
  NgwConnector.prototype.logout = function () {
4720
+ this.abort();
4719
4721
  removeConnector(this);
4720
4722
  this.options.auth = undefined;
4721
4723
  this.user = undefined;
@@ -4768,6 +4770,17 @@ var NgwConnector$1 = /** @class */ (function () {
4768
4770
  }
4769
4771
  }
4770
4772
  };
4773
+ /** Stop all api requests */
4774
+ NgwConnector.prototype.abort = function () {
4775
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
4776
+ var req = _a[_i];
4777
+ req.cancel();
4778
+ }
4779
+ this.activeRequests = [];
4780
+ };
4781
+ NgwConnector.prototype.getActiveApiRequests = function () {
4782
+ return __spreadArray([], this.activeRequests, true);
4783
+ };
4771
4784
  /**
4772
4785
  * Send request to NGW api router.
4773
4786
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -4989,7 +5002,13 @@ var NgwConnector$1 = /** @class */ (function () {
4989
5002
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
4990
5003
  }
4991
5004
  loadData(url, resolve, options, reject, onCancel);
4992
- }).catch(function (httpError) {
5005
+ })
5006
+ .then(function (resp) {
5007
+ _this._cleanActiveRequests(request);
5008
+ return resp;
5009
+ })
5010
+ .catch(function (httpError) {
5011
+ _this._cleanActiveRequests(request);
4993
5012
  if (httpError instanceof CancelablePromise.CancelError) ;
4994
5013
  else {
4995
5014
  // @ts-ignore
@@ -5008,8 +5027,15 @@ var NgwConnector$1 = /** @class */ (function () {
5008
5027
  request.cancel();
5009
5028
  });
5010
5029
  }
5030
+ this.activeRequests.push(request);
5011
5031
  return request;
5012
5032
  };
5033
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
5034
+ var activeRequestIndex = this.activeRequests.indexOf(request);
5035
+ if (activeRequestIndex !== -1) {
5036
+ this.activeRequests.splice(activeRequestIndex, 1);
5037
+ }
5038
+ };
5013
5039
  NgwConnector.prototype._handleHttpError = function (er) {
5014
5040
  if (er) {
5015
5041
  if (er instanceof NgwError) {