@ngxs/store 3.7.5-dev.master-f9549a3 → 3.7.5-dev.master-b4f4da3

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.
@@ -1786,6 +1786,15 @@
1786
1786
  function InternalActions() {
1787
1787
  return _super !== null && _super.apply(this, arguments) || this;
1788
1788
  }
1789
+ /**
1790
+ * @return {?}
1791
+ */
1792
+ InternalActions.prototype.ngOnDestroy = /**
1793
+ * @return {?}
1794
+ */
1795
+ function () {
1796
+ this.complete();
1797
+ };
1789
1798
  InternalActions.decorators = [
1790
1799
  { type: core.Injectable }
1791
1800
  ];
@@ -1891,6 +1900,126 @@
1891
1900
  })]));
1892
1901
  }); });
1893
1902
 
1903
+ /**
1904
+ * @fileoverview added by tsickle
1905
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1906
+ */
1907
+ /**
1908
+ * This operator is used for piping the observable result
1909
+ * from the `dispatch()`. It has a "smart" error handling
1910
+ * strategy that allows us to decide whether we propagate
1911
+ * errors to Angular's `ErrorHandler` or enable users to
1912
+ * handle them manually. We consider following cases:
1913
+ * 1) `store.dispatch()` (no subscribe) -> call `handleError()`
1914
+ * 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
1915
+ * 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
1916
+ * 4) `toPromise()` without `catch` -> do `handleError()`
1917
+ * 5) `toPromise()` with `catch` -> don't `handleError()`
1918
+ * @template T
1919
+ * @param {?} internalErrorReporter
1920
+ * @param {?} ngxsExecutionStrategy
1921
+ * @return {?}
1922
+ */
1923
+ function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
1924
+ return (/**
1925
+ * @param {?} source
1926
+ * @return {?}
1927
+ */
1928
+ function (source) {
1929
+ /** @type {?} */
1930
+ var subscribed = false;
1931
+ source.subscribe({
1932
+ error: (/**
1933
+ * @param {?} error
1934
+ * @return {?}
1935
+ */
1936
+ function (error) {
1937
+ // Do not trigger change detection for a microtask. This depends on the execution
1938
+ // strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
1939
+ // leaves the Angular zone.
1940
+ ngxsExecutionStrategy.enter((/**
1941
+ * @return {?}
1942
+ */
1943
+ function () {
1944
+ return Promise.resolve().then((/**
1945
+ * @return {?}
1946
+ */
1947
+ function () {
1948
+ if (!subscribed) {
1949
+ ngxsExecutionStrategy.leave((/**
1950
+ * @return {?}
1951
+ */
1952
+ function () {
1953
+ return internalErrorReporter.reportErrorSafely(error);
1954
+ }));
1955
+ }
1956
+ }));
1957
+ }));
1958
+ })
1959
+ });
1960
+ return new rxjs.Observable((/**
1961
+ * @param {?} subscriber
1962
+ * @return {?}
1963
+ */
1964
+ function (subscriber) {
1965
+ subscribed = true;
1966
+ return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
1967
+ }));
1968
+ });
1969
+ }
1970
+ var InternalErrorReporter = /** @class */ (function () {
1971
+ function InternalErrorReporter(_injector) {
1972
+ this._injector = _injector;
1973
+ /**
1974
+ * Will be set lazily to be backward compatible.
1975
+ */
1976
+ this._errorHandler = (/** @type {?} */ (null));
1977
+ }
1978
+ /**
1979
+ * @param {?} error
1980
+ * @return {?}
1981
+ */
1982
+ InternalErrorReporter.prototype.reportErrorSafely = /**
1983
+ * @param {?} error
1984
+ * @return {?}
1985
+ */
1986
+ function (error) {
1987
+ if (this._errorHandler === null) {
1988
+ this._errorHandler = this._injector.get(core.ErrorHandler);
1989
+ }
1990
+ // The `try-catch` is used to avoid handling the error twice. Suppose we call
1991
+ // `handleError` which re-throws the error internally. The re-thrown error will
1992
+ // be caught by zone.js which will then get to the `zone.onError.emit()` and the
1993
+ // `onError` subscriber will call `handleError` again.
1994
+ try {
1995
+ this._errorHandler.handleError(error);
1996
+ }
1997
+ catch (_a) { }
1998
+ };
1999
+ InternalErrorReporter.decorators = [
2000
+ { type: core.Injectable, args: [{ providedIn: 'root' },] }
2001
+ ];
2002
+ /** @nocollapse */
2003
+ InternalErrorReporter.ctorParameters = function () { return [
2004
+ { type: core.Injector }
2005
+ ]; };
2006
+ /** @nocollapse */ InternalErrorReporter.ngInjectableDef = core.defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(core.inject(core.INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
2007
+ return InternalErrorReporter;
2008
+ }());
2009
+ if (false) {
2010
+ /**
2011
+ * Will be set lazily to be backward compatible.
2012
+ * @type {?}
2013
+ * @private
2014
+ */
2015
+ InternalErrorReporter.prototype._errorHandler;
2016
+ /**
2017
+ * @type {?}
2018
+ * @private
2019
+ */
2020
+ InternalErrorReporter.prototype._injector;
2021
+ }
2022
+
1894
2023
  /**
1895
2024
  * @fileoverview added by tsickle
1896
2025
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2023,13 +2152,13 @@
2023
2152
  return InternalDispatchedActionResults;
2024
2153
  }(rxjs.Subject));
2025
2154
  var InternalDispatcher = /** @class */ (function () {
2026
- function InternalDispatcher(_injector, _actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy) {
2027
- this._injector = _injector;
2155
+ function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
2028
2156
  this._actions = _actions;
2029
2157
  this._actionResults = _actionResults;
2030
2158
  this._pluginManager = _pluginManager;
2031
2159
  this._stateStream = _stateStream;
2032
2160
  this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
2161
+ this._internalErrorReporter = _internalErrorReporter;
2033
2162
  }
2034
2163
  /**
2035
2164
  * Dispatches event(s).
@@ -2053,26 +2182,7 @@
2053
2182
  function () {
2054
2183
  return _this.dispatchByEvents(actionOrActions);
2055
2184
  }));
2056
- result.subscribe({
2057
- error: (/**
2058
- * @param {?} error
2059
- * @return {?}
2060
- */
2061
- function (error) {
2062
- return _this._ngxsExecutionStrategy.leave((/**
2063
- * @return {?}
2064
- */
2065
- function () {
2066
- try {
2067
- // Retrieve lazily to avoid cyclic dependency exception
2068
- _this._errorHandler = _this._errorHandler || _this._injector.get(core.ErrorHandler);
2069
- _this._errorHandler.handleError(error);
2070
- }
2071
- catch (_a) { }
2072
- }));
2073
- })
2074
- });
2075
- return result.pipe(leaveNgxs(this._ngxsExecutionStrategy));
2185
+ return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
2076
2186
  };
2077
2187
  /**
2078
2188
  * @private
@@ -2197,26 +2307,16 @@
2197
2307
  ];
2198
2308
  /** @nocollapse */
2199
2309
  InternalDispatcher.ctorParameters = function () { return [
2200
- { type: core.Injector },
2201
2310
  { type: InternalActions },
2202
2311
  { type: InternalDispatchedActionResults },
2203
2312
  { type: PluginManager },
2204
2313
  { type: StateStream },
2205
- { type: InternalNgxsExecutionStrategy }
2314
+ { type: InternalNgxsExecutionStrategy },
2315
+ { type: InternalErrorReporter }
2206
2316
  ]; };
2207
2317
  return InternalDispatcher;
2208
2318
  }());
2209
2319
  if (false) {
2210
- /**
2211
- * @type {?}
2212
- * @private
2213
- */
2214
- InternalDispatcher.prototype._errorHandler;
2215
- /**
2216
- * @type {?}
2217
- * @private
2218
- */
2219
- InternalDispatcher.prototype._injector;
2220
2320
  /**
2221
2321
  * @type {?}
2222
2322
  * @private
@@ -2242,6 +2342,11 @@
2242
2342
  * @private
2243
2343
  */
2244
2344
  InternalDispatcher.prototype._ngxsExecutionStrategy;
2345
+ /**
2346
+ * @type {?}
2347
+ * @private
2348
+ */
2349
+ InternalDispatcher.prototype._internalErrorReporter;
2245
2350
  }
2246
2351
 
2247
2352
  /**
@@ -3696,8 +3801,9 @@
3696
3801
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3697
3802
  */
3698
3803
  var LifecycleStateManager = /** @class */ (function () {
3699
- function LifecycleStateManager(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3804
+ function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3700
3805
  this._store = _store;
3806
+ this._internalErrorReporter = _internalErrorReporter;
3701
3807
  this._internalStateOperations = _internalStateOperations;
3702
3808
  this._stateContextFactory = _stateContextFactory;
3703
3809
  this._bootstrapper = _bootstrapper;
@@ -3735,30 +3841,36 @@
3735
3841
  function () { return !!results; })), operators.tap((/**
3736
3842
  * @return {?}
3737
3843
  */
3738
- function () { return _this._invokeInit((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
3844
+ function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
3739
3845
  * @return {?}
3740
3846
  */
3741
3847
  function () { return _this._bootstrapper.appBootstrapped$; })), operators.filter((/**
3742
3848
  * @param {?} appBootstrapped
3743
3849
  * @return {?}
3744
3850
  */
3745
- function (appBootstrapped) { return !!appBootstrapped; })), operators.takeUntil(this._destroy$))
3851
+ function (appBootstrapped) { return !!appBootstrapped; })), operators.catchError((/**
3852
+ * @param {?} error
3853
+ * @return {?}
3854
+ */
3855
+ function (error) {
3856
+ // The `SafeSubscriber` (which is used by most RxJS operators) re-throws
3857
+ // errors asynchronously (`setTimeout(() => { throw error })`). This might
3858
+ // break existing user's code or unit tests. We catch the error manually to
3859
+ // be backward compatible with the old behavior.
3860
+ _this._internalErrorReporter.reportErrorSafely(error);
3861
+ return rxjs.EMPTY;
3862
+ })), operators.takeUntil(this._destroy$))
3746
3863
  .subscribe((/**
3747
3864
  * @return {?}
3748
3865
  */
3749
- function () { return _this._invokeBootstrap((/** @type {?} */ (results)).states); }));
3866
+ function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
3750
3867
  };
3751
3868
  /**
3752
- * Invoke the init function on the states.
3753
- */
3754
- /**
3755
- * Invoke the init function on the states.
3756
3869
  * @private
3757
3870
  * @param {?} mappedStores
3758
3871
  * @return {?}
3759
3872
  */
3760
- LifecycleStateManager.prototype._invokeInit = /**
3761
- * Invoke the init function on the states.
3873
+ LifecycleStateManager.prototype._invokeInitOnStates = /**
3762
3874
  * @private
3763
3875
  * @param {?} mappedStores
3764
3876
  * @return {?}
@@ -3808,16 +3920,11 @@
3808
3920
  }
3809
3921
  };
3810
3922
  /**
3811
- * Invoke the bootstrap function on the states.
3812
- */
3813
- /**
3814
- * Invoke the bootstrap function on the states.
3815
3923
  * @private
3816
3924
  * @param {?} mappedStores
3817
3925
  * @return {?}
3818
3926
  */
3819
- LifecycleStateManager.prototype._invokeBootstrap = /**
3820
- * Invoke the bootstrap function on the states.
3927
+ LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
3821
3928
  * @private
3822
3929
  * @param {?} mappedStores
3823
3930
  * @return {?}
@@ -3861,6 +3968,7 @@
3861
3968
  /** @nocollapse */
3862
3969
  LifecycleStateManager.ctorParameters = function () { return [
3863
3970
  { type: Store },
3971
+ { type: InternalErrorReporter },
3864
3972
  { type: InternalStateOperations },
3865
3973
  { type: StateContextFactory },
3866
3974
  { type: internals.NgxsBootstrapper }
@@ -3878,6 +3986,11 @@
3878
3986
  * @private
3879
3987
  */
3880
3988
  LifecycleStateManager.prototype._store;
3989
+ /**
3990
+ * @type {?}
3991
+ * @private
3992
+ */
3993
+ LifecycleStateManager.prototype._internalErrorReporter;
3881
3994
  /**
3882
3995
  * @type {?}
3883
3996
  * @private
@@ -4744,13 +4857,14 @@
4744
4857
  exports.ɵo = InternalStateOperations;
4745
4858
  exports.ɵp = PluginManager;
4746
4859
  exports.ɵq = InternalNgxsExecutionStrategy;
4747
- exports.ɵr = SelectFactory;
4748
- exports.ɵt = ensureStoreMetadata;
4749
- exports.ɵu = getStoreMetadata;
4750
- exports.ɵv = ensureSelectorMetadata;
4751
- exports.ɵw = getSelectorMetadata;
4752
- exports.ɵx = LifecycleStateManager;
4753
- exports.ɵy = NgxsFeatureModule;
4860
+ exports.ɵr = InternalErrorReporter;
4861
+ exports.ɵs = SelectFactory;
4862
+ exports.ɵu = ensureStoreMetadata;
4863
+ exports.ɵv = getStoreMetadata;
4864
+ exports.ɵw = ensureSelectorMetadata;
4865
+ exports.ɵx = getSelectorMetadata;
4866
+ exports.ɵy = LifecycleStateManager;
4867
+ exports.ɵz = NgxsFeatureModule;
4754
4868
 
4755
4869
  Object.defineProperty(exports, '__esModule', { value: true });
4756
4870