@ngxs/store 3.7.3-dev.master-33cace6 → 3.7.3-dev.master-b00eeb3

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.
@@ -3,7 +3,7 @@ import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, Inje
3
3
  import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState, ensureInjectorNotifierIsCaptured, localInject, ensureLocalInjectorCaptured } from '@ngxs/store/internals';
4
4
  import { isPlatformServer } from '@angular/common';
5
5
  import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from } from 'rxjs';
6
- import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, distinctUntilChanged } from 'rxjs/operators';
6
+ import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, publishReplay, refCount, distinctUntilChanged } from 'rxjs/operators';
7
7
 
8
8
  /**
9
9
  * @fileoverview added by tsickle
@@ -1173,6 +1173,7 @@ if (false) {
1173
1173
  * RxJS operator for selecting out specific actions.
1174
1174
  *
1175
1175
  * This will grab actions that have just been dispatched as well as actions that have completed
1176
+ * @template T
1176
1177
  * @param {...?} allowedTypes
1177
1178
  * @return {?}
1178
1179
  */
@@ -1187,6 +1188,7 @@ function ofAction() {
1187
1188
  * RxJS operator for selecting out specific actions.
1188
1189
  *
1189
1190
  * This will ONLY grab actions that have just been dispatched
1191
+ * @template T
1190
1192
  * @param {...?} allowedTypes
1191
1193
  * @return {?}
1192
1194
  */
@@ -1201,6 +1203,7 @@ function ofActionDispatched() {
1201
1203
  * RxJS operator for selecting out specific actions.
1202
1204
  *
1203
1205
  * This will ONLY grab actions that have just been successfully completed
1206
+ * @template T
1204
1207
  * @param {...?} allowedTypes
1205
1208
  * @return {?}
1206
1209
  */
@@ -1215,6 +1218,7 @@ function ofActionSuccessful() {
1215
1218
  * RxJS operator for selecting out specific actions.
1216
1219
  *
1217
1220
  * This will ONLY grab actions that have just been canceled
1221
+ * @template T
1218
1222
  * @param {...?} allowedTypes
1219
1223
  * @return {?}
1220
1224
  */
@@ -1229,6 +1233,7 @@ function ofActionCanceled() {
1229
1233
  * RxJS operator for selecting out specific actions.
1230
1234
  *
1231
1235
  * This will ONLY grab actions that have just been completed
1236
+ * @template T
1232
1237
  * @param {...?} allowedTypes
1233
1238
  * @return {?}
1234
1239
  */
@@ -1249,6 +1254,7 @@ function ofActionCompleted() {
1249
1254
  * RxJS operator for selecting out specific actions.
1250
1255
  *
1251
1256
  * This will ONLY grab actions that have just thrown an error
1257
+ * @template T
1252
1258
  * @param {...?} allowedTypes
1253
1259
  * @return {?}
1254
1260
  */
@@ -3426,6 +3432,12 @@ var Store = /** @class */ (function () {
3426
3432
  this._config = _config;
3427
3433
  this._internalExecutionStrategy = _internalExecutionStrategy;
3428
3434
  this._stateFactory = _stateFactory;
3435
+ /**
3436
+ * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
3437
+ * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
3438
+ * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
3439
+ */
3440
+ this._selectableStateStream = this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy), publishReplay(1), refCount());
3429
3441
  this.initStateStream(initialStateValue);
3430
3442
  }
3431
3443
  /**
@@ -3456,7 +3468,7 @@ var Store = /** @class */ (function () {
3456
3468
  var _this = this;
3457
3469
  /** @type {?} */
3458
3470
  var selectorFn = this.getStoreBoundSelectorFn(selector);
3459
- return this._stateStream.pipe(map(selectorFn), catchError((/**
3471
+ return this._selectableStateStream.pipe(map(selectorFn), catchError((/**
3460
3472
  * @param {?} err
3461
3473
  * @return {?}
3462
3474
  */
@@ -3508,7 +3520,9 @@ var Store = /** @class */ (function () {
3508
3520
  * @return {?}
3509
3521
  */
3510
3522
  function (fn) {
3511
- return this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy)).subscribe(fn);
3523
+ return this._selectableStateStream
3524
+ .pipe(leaveNgxs(this._internalExecutionStrategy))
3525
+ .subscribe(fn);
3512
3526
  };
3513
3527
  /**
3514
3528
  * Return the raw value of the state.
@@ -3599,6 +3613,14 @@ var Store = /** @class */ (function () {
3599
3613
  return Store;
3600
3614
  }());
3601
3615
  if (false) {
3616
+ /**
3617
+ * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
3618
+ * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
3619
+ * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
3620
+ * @type {?}
3621
+ * @private
3622
+ */
3623
+ Store.prototype._selectableStateStream;
3602
3624
  /**
3603
3625
  * @type {?}
3604
3626
  * @private