@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
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, isObject, defined, deprecatedWarn } from '@nextgis/utils';
@@ -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
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -4634,6 +4634,7 @@ var NgwMap = (function (exports) {
4634
4634
  this.id = ID$1++;
4635
4635
  this.emitter = new events.exports.EventEmitter();
4636
4636
  this.routeStr = '/api/component/pyramid/route';
4637
+ this.activeRequests = [];
4637
4638
  var exist = findConnector(options);
4638
4639
  if (exist) {
4639
4640
  return exist;
@@ -4719,6 +4720,7 @@ var NgwMap = (function (exports) {
4719
4720
  * Disconnecting a user. Aborting all current requests
4720
4721
  */
4721
4722
  NgwConnector.prototype.logout = function () {
4723
+ this.abort();
4722
4724
  removeConnector(this);
4723
4725
  this.options.auth = undefined;
4724
4726
  this.user = undefined;
@@ -4771,6 +4773,17 @@ var NgwMap = (function (exports) {
4771
4773
  }
4772
4774
  }
4773
4775
  };
4776
+ /** Stop all api requests */
4777
+ NgwConnector.prototype.abort = function () {
4778
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
4779
+ var req = _a[_i];
4780
+ req.cancel();
4781
+ }
4782
+ this.activeRequests = [];
4783
+ };
4784
+ NgwConnector.prototype.getActiveApiRequests = function () {
4785
+ return __spreadArray([], this.activeRequests, true);
4786
+ };
4774
4787
  /**
4775
4788
  * Send request to NGW api router.
4776
4789
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -4992,7 +5005,13 @@ var NgwMap = (function (exports) {
4992
5005
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
4993
5006
  }
4994
5007
  loadData(url, resolve, options, reject, onCancel);
4995
- }).catch(function (httpError) {
5008
+ })
5009
+ .then(function (resp) {
5010
+ _this._cleanActiveRequests(request);
5011
+ return resp;
5012
+ })
5013
+ .catch(function (httpError) {
5014
+ _this._cleanActiveRequests(request);
4996
5015
  if (httpError instanceof CancelablePromise.CancelError) ;
4997
5016
  else {
4998
5017
  // @ts-ignore
@@ -5011,8 +5030,15 @@ var NgwMap = (function (exports) {
5011
5030
  request.cancel();
5012
5031
  });
5013
5032
  }
5033
+ this.activeRequests.push(request);
5014
5034
  return request;
5015
5035
  };
5036
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
5037
+ var activeRequestIndex = this.activeRequests.indexOf(request);
5038
+ if (activeRequestIndex !== -1) {
5039
+ this.activeRequests.splice(activeRequestIndex, 1);
5040
+ }
5041
+ };
5016
5042
  NgwConnector.prototype._handleHttpError = function (er) {
5017
5043
  if (er) {
5018
5044
  if (er instanceof NgwError) {