@senior-gestao-empresarial/angular-components 6.9.3 → 6.10.1

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.
@@ -7238,15 +7238,14 @@
7238
7238
  /** @private */
7239
7239
  this.primitiveManagers = new Map();
7240
7240
  /** @private */
7241
- this.connect$ = new rxjs.Subject();
7241
+ this.connected$ = new rxjs.BehaviorSubject(false);
7242
7242
  /** @private */
7243
7243
  this.disconnect$ = new rxjs.Subject();
7244
7244
  /** @private */
7245
7245
  this.reconnect$ = new rxjs.Subject();
7246
7246
  /** @private */
7247
7247
  this.error$ = new rxjs.Subject();
7248
- this.subscribe$ = new rxjs.Subject();
7249
- this.connect();
7248
+ this.subscribed$ = new rxjs.Subject();
7250
7249
  }
7251
7250
  WebsocketService_1 = WebsocketService;
7252
7251
  /**
@@ -7254,10 +7253,7 @@
7254
7253
  * @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
7255
7254
  */
7256
7255
  WebsocketService.prototype.onConnect = function () {
7257
- if (this.isConnected || this.wasConnected) {
7258
- return rxjs.of(undefined).pipe(operators.take(1));
7259
- }
7260
- return this.connect$.asObservable().pipe(operators.take(1));
7256
+ return this.connected$.asObservable().pipe(operators.filter(Boolean), operators.map(function () { return undefined; }), operators.take(1));
7261
7257
  };
7262
7258
  /**
7263
7259
  * Observable responsável por emitir uma notificação quando a conexão é desconectada.
@@ -7282,12 +7278,14 @@
7282
7278
  var domain = _a.domain, service = _a.service, primitive = _a.primitive;
7283
7279
  var key = this.getPrimitiveManagerKey(domain, service, primitive);
7284
7280
  return this.onConnect().pipe(operators.switchMap(function () {
7285
- return _this.primitiveManagers.has(key) &&
7286
- _this.primitiveManagers.get(key).isSubscribed
7287
- ? rxjs.of(void 0).pipe(operators.take(1))
7288
- : _this.subscribe$.pipe(operators.filter(function (primitiveManager) {
7289
- return _this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
7290
- }), operators.take(1), operators.map(function () { return void 0; }));
7281
+ if (_this.primitiveManagers.has(key))
7282
+ return _this.primitiveManagers
7283
+ .get(key)
7284
+ .subscribed$.asObservable()
7285
+ .pipe(operators.map(function () { return undefined; }), operators.take(1));
7286
+ return _this.subscribed$.asObservable().pipe(operators.filter(function (primitiveManager) {
7287
+ return _this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
7288
+ }), operators.map(function () { return undefined; }), operators.take(1));
7291
7289
  }));
7292
7290
  };
7293
7291
  /**
@@ -7307,6 +7305,7 @@
7307
7305
  */
7308
7306
  WebsocketService.prototype.onEvent = function (options) {
7309
7307
  var _this = this;
7308
+ this.connect();
7310
7309
  var domain = options.domain, service = options.service, primitive = options.primitive;
7311
7310
  var key = this.getPrimitiveManagerKey(domain, service, primitive);
7312
7311
  if (this.primitiveManagers.has(key)) {
@@ -7318,30 +7317,17 @@
7318
7317
  primitive: primitive,
7319
7318
  stompSubscriptions: [],
7320
7319
  event$: new rxjs.Subject(),
7321
- isSubscribed: false
7320
+ subscribed$: new rxjs.BehaviorSubject(false)
7322
7321
  };
7323
7322
  this.primitiveManagers.set(key, primitiveManager);
7324
- if (this.isConnected) {
7325
- this.createStompSubscriptions(primitiveManager);
7326
- return primitiveManager.event$
7327
- .asObservable()
7328
- .pipe(operators.finalize(function () {
7329
- return _this.disconnectPrimitiveOnFinalize(primitiveManager);
7330
- }));
7331
- }
7332
- else {
7333
- if (!this.isConnecting) {
7334
- this.connect();
7335
- }
7336
- this.connect$.pipe(operators.first()).subscribe(function () {
7337
- _this.createStompSubscriptions(primitiveManager);
7338
- });
7339
- return primitiveManager.event$
7340
- .asObservable()
7341
- .pipe(operators.finalize(function () {
7342
- return _this.disconnectPrimitiveOnFinalize(primitiveManager);
7343
- }));
7344
- }
7323
+ this.onConnect()
7324
+ .pipe(operators.take(1))
7325
+ .subscribe(function () {
7326
+ _this.createStompSubscriptions(primitiveManager);
7327
+ });
7328
+ return primitiveManager.event$
7329
+ .asObservable()
7330
+ .pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
7345
7331
  };
7346
7332
  /** @private */
7347
7333
  WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
@@ -7353,12 +7339,14 @@
7353
7339
  stompSubscriptionWithToken,
7354
7340
  stompSubscriptionWithoutToken
7355
7341
  ];
7356
- primitiveManager.isSubscribed = true;
7357
- this.subscribe$.next(primitiveManager);
7342
+ primitiveManager.subscribed$.next(true);
7343
+ this.subscribed$.next(primitiveManager);
7358
7344
  };
7359
7345
  /** @private */
7360
7346
  WebsocketService.prototype.connect = function () {
7361
7347
  var _this = this;
7348
+ if (this.isConnected || this.isConnecting)
7349
+ return;
7362
7350
  this.createStompClient();
7363
7351
  this.isConnecting = true;
7364
7352
  this._stompClient.connect({}, function () {
@@ -7366,15 +7354,16 @@
7366
7354
  _this.isConnected = true;
7367
7355
  if (_this.wasConnected) {
7368
7356
  _this.reconnectPrimitives();
7369
- _this.connect$.next();
7357
+ _this.connected$.next(true);
7370
7358
  _this.reconnect$.next();
7371
7359
  }
7372
7360
  else {
7373
7361
  _this.wasConnected = true;
7374
- _this.connect$.next();
7362
+ _this.connected$.next(true);
7375
7363
  }
7376
7364
  }, function (error) {
7377
7365
  _this.isConnected = false;
7366
+ _this.connected$.next(false);
7378
7367
  _this.error$.next(error);
7379
7368
  rxjs.race(_this.disconnect$.pipe(operators.take(1), operators.map(function () { return ({ wasDisconnected: true }); })), rxjs.timer(WebsocketService_1.RECONNECT_INTERVAL).pipe(operators.take(1), operators.switchMap(function () {
7380
7369
  return rxjs.iif(function () { return document.hidden; }, rxjs.fromEvent(document, 'visibilitychange').pipe(operators.first()), rxjs.of(void 0));
@@ -7393,7 +7382,7 @@
7393
7382
  };
7394
7383
  WebsocketService.prototype.disconnect = function () {
7395
7384
  var e_1, _a, e_2, _b, e_3, _c;
7396
- if (this.getObserversCount() > 0) {
7385
+ if (!this.isConnected || this.getObserversCount() > 0) {
7397
7386
  return;
7398
7387
  }
7399
7388
  try {
@@ -7440,6 +7429,7 @@
7440
7429
  this.isConnected = false;
7441
7430
  this.isConnecting = false;
7442
7431
  this.wasConnected = false;
7432
+ this.connected$.next(false);
7443
7433
  this.disconnect$.next();
7444
7434
  };
7445
7435
  /** @private */
@@ -7529,6 +7519,7 @@
7529
7519
  }
7530
7520
  finally { if (e_6) throw e_6.error; }
7531
7521
  }
7522
+ primitiveManager.subscribed$.complete();
7532
7523
  var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
7533
7524
  this.primitiveManagers.delete(key);
7534
7525
  this.disconnect();