@ngxs/store 3.7.3-dev.master-5b116c1 → 3.7.3-dev.master-cdd7ae3

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.
@@ -382,13 +382,14 @@
382
382
  return func();
383
383
  };
384
384
  DispatchOutsideZoneNgxsExecutionStrategy.decorators = [
385
- { type: core.Injectable }
385
+ { type: core.Injectable, args: [{ providedIn: 'root' },] }
386
386
  ];
387
387
  /** @nocollapse */
388
388
  DispatchOutsideZoneNgxsExecutionStrategy.ctorParameters = function () { return [
389
389
  { type: core.NgZone },
390
390
  { type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
391
391
  ]; };
392
+ /** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ngInjectableDef = core.defineInjectable({ factory: function DispatchOutsideZoneNgxsExecutionStrategy_Factory() { return new DispatchOutsideZoneNgxsExecutionStrategy(core.inject(core.NgZone), core.inject(core.PLATFORM_ID)); }, token: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: "root" });
392
393
  return DispatchOutsideZoneNgxsExecutionStrategy;
393
394
  }());
394
395
  if (false) {
@@ -472,6 +473,9 @@
472
473
  * Run in development mode. This will add additional debugging features:
473
474
  * - Object.freeze on the state and actions to guarantee immutability
474
475
  * (default: false)
476
+ *
477
+ * @deprecated This property is no longer necessary when the Ivy compiler is used.
478
+ * We'll determine the development mode through the `ngDevMode`. It's still essential with View Engine.
475
479
  * @type {?}
476
480
  */
477
481
  NgxsConfig.prototype.developmentMode;
@@ -640,11 +644,72 @@
640
644
  * @fileoverview added by tsickle
641
645
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
642
646
  */
647
+ var NoopNgxsExecutionStrategy = /** @class */ (function () {
648
+ function NoopNgxsExecutionStrategy() {
649
+ }
650
+ /**
651
+ * @template T
652
+ * @param {?} func
653
+ * @return {?}
654
+ */
655
+ NoopNgxsExecutionStrategy.prototype.enter = /**
656
+ * @template T
657
+ * @param {?} func
658
+ * @return {?}
659
+ */
660
+ function (func) {
661
+ return func();
662
+ };
663
+ /**
664
+ * @template T
665
+ * @param {?} func
666
+ * @return {?}
667
+ */
668
+ NoopNgxsExecutionStrategy.prototype.leave = /**
669
+ * @template T
670
+ * @param {?} func
671
+ * @return {?}
672
+ */
673
+ function (func) {
674
+ return func();
675
+ };
676
+ NoopNgxsExecutionStrategy.decorators = [
677
+ { type: core.Injectable, args: [{ providedIn: 'root' },] }
678
+ ];
679
+ /** @nocollapse */ NoopNgxsExecutionStrategy.ngInjectableDef = core.defineInjectable({ factory: function NoopNgxsExecutionStrategy_Factory() { return new NoopNgxsExecutionStrategy(); }, token: NoopNgxsExecutionStrategy, providedIn: "root" });
680
+ return NoopNgxsExecutionStrategy;
681
+ }());
682
+
683
+ /**
684
+ * @fileoverview added by tsickle
685
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
686
+ */
687
+ /**
688
+ * The strategy that might be provided by users through `options.executionStrategy`.
689
+ * @type {?}
690
+ */
691
+ var USER_PROVIDED_NGXS_EXECUTION_STRATEGY = new core.InjectionToken('USER_PROVIDED_NGXS_EXECUTION_STRATEGY');
643
692
  /*
644
693
  * Internal execution strategy injection token
645
694
  */
646
695
  /** @type {?} */
647
- var NGXS_EXECUTION_STRATEGY = new core.InjectionToken('NGXS_EXECUTION_STRATEGY');
696
+ var NGXS_EXECUTION_STRATEGY = new core.InjectionToken('NGXS_EXECUTION_STRATEGY', {
697
+ providedIn: 'root',
698
+ factory: (/**
699
+ * @return {?}
700
+ */
701
+ function () {
702
+ /** @type {?} */
703
+ var injector = core.inject(core.INJECTOR);
704
+ /** @type {?} */
705
+ var executionStrategy = injector.get(USER_PROVIDED_NGXS_EXECUTION_STRATEGY);
706
+ return executionStrategy
707
+ ? injector.get(executionStrategy)
708
+ : injector.get(typeof core.ɵglobal.Zone !== 'undefined'
709
+ ? DispatchOutsideZoneNgxsExecutionStrategy
710
+ : NoopNgxsExecutionStrategy);
711
+ })
712
+ });
648
713
  /**
649
714
  * @record
650
715
  */
@@ -1856,6 +1921,18 @@
1856
1921
  function StateStream() {
1857
1922
  return _super.call(this, {}) || this;
1858
1923
  }
1924
+ /**
1925
+ * @return {?}
1926
+ */
1927
+ StateStream.prototype.ngOnDestroy = /**
1928
+ * @return {?}
1929
+ */
1930
+ function () {
1931
+ // The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
1932
+ // This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
1933
+ // might forget to unsubscribe from `store.select` or `store.subscribe`, thus this will lead to huge memory leaks in SSR apps.
1934
+ this.complete();
1935
+ };
1859
1936
  StateStream.decorators = [
1860
1937
  { type: core.Injectable }
1861
1938
  ];
@@ -2261,9 +2338,22 @@
2261
2338
  */
2262
2339
  function (actionOrActions) { return _this._dispatcher.dispatch(actionOrActions); })
2263
2340
  };
2264
- return this._config.developmentMode
2265
- ? ensureStateAndActionsAreImmutable(rootStateOperations)
2266
- : rootStateOperations;
2341
+ // We have to have that duplication since this will allow us to tree-shake `ensureStateAndActionsAreImmutable`
2342
+ // and `deepFreeze` in Ivy production build.
2343
+ // The below `if` condition checks 2 things:
2344
+ // 1) if we're in View Engine (`ngDevMode` is `undefined`)
2345
+ // 2) if we're running tests, we should fallback to `config.developmentMode` to be backwards-compatible
2346
+ if (typeof ngDevMode === 'undefined' || (ngDevMode && internals.isAngularInTestMode())) {
2347
+ return this._config.developmentMode
2348
+ ? ensureStateAndActionsAreImmutable(rootStateOperations)
2349
+ : rootStateOperations;
2350
+ }
2351
+ else {
2352
+ // If we're in Ivy and not running tests, then tree-shake `ensureStateAndActionsAreImmutable` and `deepFreeze`.
2353
+ return ngDevMode
2354
+ ? ensureStateAndActionsAreImmutable(rootStateOperations)
2355
+ : rootStateOperations;
2356
+ }
2267
2357
  };
2268
2358
  /**
2269
2359
  * @param {?} results
@@ -2310,7 +2400,6 @@
2310
2400
  */
2311
2401
  InternalStateOperations.prototype._config;
2312
2402
  }
2313
- // We make it as a separate function and not the class method to tree-shake it in the future.
2314
2403
  /**
2315
2404
  * @param {?} root
2316
2405
  * @return {?}
@@ -4038,8 +4127,8 @@
4038
4127
  function (states, options) {
4039
4128
  return [
4040
4129
  {
4041
- provide: NGXS_EXECUTION_STRATEGY,
4042
- useClass: options.executionStrategy || DispatchOutsideZoneNgxsExecutionStrategy
4130
+ provide: USER_PROVIDED_NGXS_EXECUTION_STRATEGY,
4131
+ useValue: options.executionStrategy
4043
4132
  },
4044
4133
  {
4045
4134
  provide: ROOT_STATE_TOKEN,
@@ -4614,45 +4703,6 @@
4614
4703
  });
4615
4704
  }
4616
4705
 
4617
- /**
4618
- * @fileoverview added by tsickle
4619
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4620
- */
4621
- var NoopNgxsExecutionStrategy = /** @class */ (function () {
4622
- function NoopNgxsExecutionStrategy() {
4623
- }
4624
- /**
4625
- * @template T
4626
- * @param {?} func
4627
- * @return {?}
4628
- */
4629
- NoopNgxsExecutionStrategy.prototype.enter = /**
4630
- * @template T
4631
- * @param {?} func
4632
- * @return {?}
4633
- */
4634
- function (func) {
4635
- return func();
4636
- };
4637
- /**
4638
- * @template T
4639
- * @param {?} func
4640
- * @return {?}
4641
- */
4642
- NoopNgxsExecutionStrategy.prototype.leave = /**
4643
- * @template T
4644
- * @param {?} func
4645
- * @return {?}
4646
- */
4647
- function (func) {
4648
- return func();
4649
- };
4650
- NoopNgxsExecutionStrategy.decorators = [
4651
- { type: core.Injectable }
4652
- ];
4653
- return NoopNgxsExecutionStrategy;
4654
- }());
4655
-
4656
4706
  /**
4657
4707
  * @fileoverview added by tsickle
4658
4708
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4742,22 +4792,22 @@
4742
4792
  exports.ɵe = SELECTOR_META_KEY;
4743
4793
  exports.ɵf = NgxsConfig;
4744
4794
  exports.ɵg = mergeDeep;
4745
- exports.ɵh = NGXS_EXECUTION_STRATEGY;
4746
- exports.ɵi = NgxsRootModule;
4747
- exports.ɵj = StateFactory;
4748
- exports.ɵk = InternalDispatchedActionResults;
4749
- exports.ɵl = InternalDispatcher;
4750
- exports.ɵm = StateContextFactory;
4751
- exports.ɵn = InternalStateOperations;
4752
- exports.ɵo = PluginManager;
4753
- exports.ɵp = InternalNgxsExecutionStrategy;
4754
- exports.ɵr = ensureStoreMetadata;
4755
- exports.ɵs = getStoreMetadata;
4756
- exports.ɵt = ensureSelectorMetadata;
4757
- exports.ɵu = getSelectorMetadata;
4758
- exports.ɵv = LifecycleStateManager;
4759
- exports.ɵw = NgxsFeatureModule;
4760
- exports.ɵx = DispatchOutsideZoneNgxsExecutionStrategy;
4795
+ exports.ɵh = USER_PROVIDED_NGXS_EXECUTION_STRATEGY;
4796
+ exports.ɵi = NGXS_EXECUTION_STRATEGY;
4797
+ exports.ɵj = NgxsRootModule;
4798
+ exports.ɵk = StateFactory;
4799
+ exports.ɵl = InternalDispatchedActionResults;
4800
+ exports.ɵm = InternalDispatcher;
4801
+ exports.ɵn = StateContextFactory;
4802
+ exports.ɵo = InternalStateOperations;
4803
+ exports.ɵp = PluginManager;
4804
+ exports.ɵq = InternalNgxsExecutionStrategy;
4805
+ exports.ɵs = ensureStoreMetadata;
4806
+ exports.ɵt = getStoreMetadata;
4807
+ exports.ɵu = ensureSelectorMetadata;
4808
+ exports.ɵv = getSelectorMetadata;
4809
+ exports.ɵw = LifecycleStateManager;
4810
+ exports.ɵx = NgxsFeatureModule;
4761
4811
 
4762
4812
  Object.defineProperty(exports, '__esModule', { value: true });
4763
4813