@ngxs/store 3.7.5-dev.master-0da56b4 → 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.
- package/bundles/ngxs-store.umd.js +162 -57
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.min.js +1 -1
- package/bundles/ngxs-store.umd.min.js.map +1 -1
- package/esm2015/ngxs-store.js +6 -5
- package/esm2015/src/internal/dispatcher.js +14 -36
- package/esm2015/src/internal/error-handler.js +118 -0
- package/esm2015/src/internal/lifecycle-state-manager.js +29 -11
- package/esm5/ngxs-store.js +6 -5
- package/esm5/src/internal/dispatcher.js +13 -37
- package/esm5/src/internal/error-handler.js +125 -0
- package/esm5/src/internal/lifecycle-state-manager.js +28 -19
- package/fesm2015/ngxs-store.js +152 -43
- package/fesm2015/ngxs-store.js.map +1 -1
- package/fesm5/ngxs-store.js +156 -52
- package/fesm5/ngxs-store.js.map +1 -1
- package/ngxs-store.d.ts +6 -5
- package/ngxs-store.metadata.json +1 -1
- package/package.json +1 -1
- package/src/internal/dispatcher.d.ts +3 -4
- package/src/internal/error-handler.d.ts +23 -0
- package/src/internal/lifecycle-state-manager.d.ts +5 -9
package/fesm5/ngxs-store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __spread, __extends, __values, __read } from 'tslib';
|
|
2
|
-
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal,
|
|
2
|
+
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, ErrorHandler, Injector, Optional, SkipSelf, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
3
3
|
import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
4
4
|
import { isPlatformServer } from '@angular/common';
|
|
5
5
|
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, queueScheduler } from 'rxjs';
|
|
@@ -1682,6 +1682,126 @@ function () {
|
|
|
1682
1682
|
})]));
|
|
1683
1683
|
}); });
|
|
1684
1684
|
|
|
1685
|
+
/**
|
|
1686
|
+
* @fileoverview added by tsickle
|
|
1687
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1688
|
+
*/
|
|
1689
|
+
/**
|
|
1690
|
+
* This operator is used for piping the observable result
|
|
1691
|
+
* from the `dispatch()`. It has a "smart" error handling
|
|
1692
|
+
* strategy that allows us to decide whether we propagate
|
|
1693
|
+
* errors to Angular's `ErrorHandler` or enable users to
|
|
1694
|
+
* handle them manually. We consider following cases:
|
|
1695
|
+
* 1) `store.dispatch()` (no subscribe) -> call `handleError()`
|
|
1696
|
+
* 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
|
|
1697
|
+
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
1698
|
+
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
1699
|
+
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
1700
|
+
* @template T
|
|
1701
|
+
* @param {?} internalErrorReporter
|
|
1702
|
+
* @param {?} ngxsExecutionStrategy
|
|
1703
|
+
* @return {?}
|
|
1704
|
+
*/
|
|
1705
|
+
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
1706
|
+
return (/**
|
|
1707
|
+
* @param {?} source
|
|
1708
|
+
* @return {?}
|
|
1709
|
+
*/
|
|
1710
|
+
function (source) {
|
|
1711
|
+
/** @type {?} */
|
|
1712
|
+
var subscribed = false;
|
|
1713
|
+
source.subscribe({
|
|
1714
|
+
error: (/**
|
|
1715
|
+
* @param {?} error
|
|
1716
|
+
* @return {?}
|
|
1717
|
+
*/
|
|
1718
|
+
function (error) {
|
|
1719
|
+
// Do not trigger change detection for a microtask. This depends on the execution
|
|
1720
|
+
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
1721
|
+
// leaves the Angular zone.
|
|
1722
|
+
ngxsExecutionStrategy.enter((/**
|
|
1723
|
+
* @return {?}
|
|
1724
|
+
*/
|
|
1725
|
+
function () {
|
|
1726
|
+
return Promise.resolve().then((/**
|
|
1727
|
+
* @return {?}
|
|
1728
|
+
*/
|
|
1729
|
+
function () {
|
|
1730
|
+
if (!subscribed) {
|
|
1731
|
+
ngxsExecutionStrategy.leave((/**
|
|
1732
|
+
* @return {?}
|
|
1733
|
+
*/
|
|
1734
|
+
function () {
|
|
1735
|
+
return internalErrorReporter.reportErrorSafely(error);
|
|
1736
|
+
}));
|
|
1737
|
+
}
|
|
1738
|
+
}));
|
|
1739
|
+
}));
|
|
1740
|
+
})
|
|
1741
|
+
});
|
|
1742
|
+
return new Observable((/**
|
|
1743
|
+
* @param {?} subscriber
|
|
1744
|
+
* @return {?}
|
|
1745
|
+
*/
|
|
1746
|
+
function (subscriber) {
|
|
1747
|
+
subscribed = true;
|
|
1748
|
+
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
1749
|
+
}));
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
var InternalErrorReporter = /** @class */ (function () {
|
|
1753
|
+
function InternalErrorReporter(_injector) {
|
|
1754
|
+
this._injector = _injector;
|
|
1755
|
+
/**
|
|
1756
|
+
* Will be set lazily to be backward compatible.
|
|
1757
|
+
*/
|
|
1758
|
+
this._errorHandler = (/** @type {?} */ (null));
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* @param {?} error
|
|
1762
|
+
* @return {?}
|
|
1763
|
+
*/
|
|
1764
|
+
InternalErrorReporter.prototype.reportErrorSafely = /**
|
|
1765
|
+
* @param {?} error
|
|
1766
|
+
* @return {?}
|
|
1767
|
+
*/
|
|
1768
|
+
function (error) {
|
|
1769
|
+
if (this._errorHandler === null) {
|
|
1770
|
+
this._errorHandler = this._injector.get(ErrorHandler);
|
|
1771
|
+
}
|
|
1772
|
+
// The `try-catch` is used to avoid handling the error twice. Suppose we call
|
|
1773
|
+
// `handleError` which re-throws the error internally. The re-thrown error will
|
|
1774
|
+
// be caught by zone.js which will then get to the `zone.onError.emit()` and the
|
|
1775
|
+
// `onError` subscriber will call `handleError` again.
|
|
1776
|
+
try {
|
|
1777
|
+
this._errorHandler.handleError(error);
|
|
1778
|
+
}
|
|
1779
|
+
catch (_a) { }
|
|
1780
|
+
};
|
|
1781
|
+
InternalErrorReporter.decorators = [
|
|
1782
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
1783
|
+
];
|
|
1784
|
+
/** @nocollapse */
|
|
1785
|
+
InternalErrorReporter.ctorParameters = function () { return [
|
|
1786
|
+
{ type: Injector }
|
|
1787
|
+
]; };
|
|
1788
|
+
/** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
|
|
1789
|
+
return InternalErrorReporter;
|
|
1790
|
+
}());
|
|
1791
|
+
if (false) {
|
|
1792
|
+
/**
|
|
1793
|
+
* Will be set lazily to be backward compatible.
|
|
1794
|
+
* @type {?}
|
|
1795
|
+
* @private
|
|
1796
|
+
*/
|
|
1797
|
+
InternalErrorReporter.prototype._errorHandler;
|
|
1798
|
+
/**
|
|
1799
|
+
* @type {?}
|
|
1800
|
+
* @private
|
|
1801
|
+
*/
|
|
1802
|
+
InternalErrorReporter.prototype._injector;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1685
1805
|
/**
|
|
1686
1806
|
* @fileoverview added by tsickle
|
|
1687
1807
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -1814,13 +1934,13 @@ var InternalDispatchedActionResults = /** @class */ (function (_super) {
|
|
|
1814
1934
|
return InternalDispatchedActionResults;
|
|
1815
1935
|
}(Subject));
|
|
1816
1936
|
var InternalDispatcher = /** @class */ (function () {
|
|
1817
|
-
function InternalDispatcher(
|
|
1818
|
-
this._injector = _injector;
|
|
1937
|
+
function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
|
|
1819
1938
|
this._actions = _actions;
|
|
1820
1939
|
this._actionResults = _actionResults;
|
|
1821
1940
|
this._pluginManager = _pluginManager;
|
|
1822
1941
|
this._stateStream = _stateStream;
|
|
1823
1942
|
this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
|
|
1943
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
1824
1944
|
}
|
|
1825
1945
|
/**
|
|
1826
1946
|
* Dispatches event(s).
|
|
@@ -1844,26 +1964,7 @@ var InternalDispatcher = /** @class */ (function () {
|
|
|
1844
1964
|
function () {
|
|
1845
1965
|
return _this.dispatchByEvents(actionOrActions);
|
|
1846
1966
|
}));
|
|
1847
|
-
result.
|
|
1848
|
-
error: (/**
|
|
1849
|
-
* @param {?} error
|
|
1850
|
-
* @return {?}
|
|
1851
|
-
*/
|
|
1852
|
-
function (error) {
|
|
1853
|
-
return _this._ngxsExecutionStrategy.leave((/**
|
|
1854
|
-
* @return {?}
|
|
1855
|
-
*/
|
|
1856
|
-
function () {
|
|
1857
|
-
try {
|
|
1858
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
1859
|
-
_this._errorHandler = _this._errorHandler || _this._injector.get(ErrorHandler);
|
|
1860
|
-
_this._errorHandler.handleError(error);
|
|
1861
|
-
}
|
|
1862
|
-
catch (_a) { }
|
|
1863
|
-
}));
|
|
1864
|
-
})
|
|
1865
|
-
});
|
|
1866
|
-
return result.pipe(leaveNgxs(this._ngxsExecutionStrategy));
|
|
1967
|
+
return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
|
|
1867
1968
|
};
|
|
1868
1969
|
/**
|
|
1869
1970
|
* @private
|
|
@@ -1988,26 +2089,16 @@ var InternalDispatcher = /** @class */ (function () {
|
|
|
1988
2089
|
];
|
|
1989
2090
|
/** @nocollapse */
|
|
1990
2091
|
InternalDispatcher.ctorParameters = function () { return [
|
|
1991
|
-
{ type: Injector },
|
|
1992
2092
|
{ type: InternalActions },
|
|
1993
2093
|
{ type: InternalDispatchedActionResults },
|
|
1994
2094
|
{ type: PluginManager },
|
|
1995
2095
|
{ type: StateStream },
|
|
1996
|
-
{ type: InternalNgxsExecutionStrategy }
|
|
2096
|
+
{ type: InternalNgxsExecutionStrategy },
|
|
2097
|
+
{ type: InternalErrorReporter }
|
|
1997
2098
|
]; };
|
|
1998
2099
|
return InternalDispatcher;
|
|
1999
2100
|
}());
|
|
2000
2101
|
if (false) {
|
|
2001
|
-
/**
|
|
2002
|
-
* @type {?}
|
|
2003
|
-
* @private
|
|
2004
|
-
*/
|
|
2005
|
-
InternalDispatcher.prototype._errorHandler;
|
|
2006
|
-
/**
|
|
2007
|
-
* @type {?}
|
|
2008
|
-
* @private
|
|
2009
|
-
*/
|
|
2010
|
-
InternalDispatcher.prototype._injector;
|
|
2011
2102
|
/**
|
|
2012
2103
|
* @type {?}
|
|
2013
2104
|
* @private
|
|
@@ -2033,6 +2124,11 @@ if (false) {
|
|
|
2033
2124
|
* @private
|
|
2034
2125
|
*/
|
|
2035
2126
|
InternalDispatcher.prototype._ngxsExecutionStrategy;
|
|
2127
|
+
/**
|
|
2128
|
+
* @type {?}
|
|
2129
|
+
* @private
|
|
2130
|
+
*/
|
|
2131
|
+
InternalDispatcher.prototype._internalErrorReporter;
|
|
2036
2132
|
}
|
|
2037
2133
|
|
|
2038
2134
|
/**
|
|
@@ -3487,8 +3583,9 @@ if (false) {
|
|
|
3487
3583
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3488
3584
|
*/
|
|
3489
3585
|
var LifecycleStateManager = /** @class */ (function () {
|
|
3490
|
-
function LifecycleStateManager(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3586
|
+
function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3491
3587
|
this._store = _store;
|
|
3588
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
3492
3589
|
this._internalStateOperations = _internalStateOperations;
|
|
3493
3590
|
this._stateContextFactory = _stateContextFactory;
|
|
3494
3591
|
this._bootstrapper = _bootstrapper;
|
|
@@ -3526,30 +3623,36 @@ var LifecycleStateManager = /** @class */ (function () {
|
|
|
3526
3623
|
function () { return !!results; })), tap((/**
|
|
3527
3624
|
* @return {?}
|
|
3528
3625
|
*/
|
|
3529
|
-
function () { return _this.
|
|
3626
|
+
function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), mergeMap((/**
|
|
3530
3627
|
* @return {?}
|
|
3531
3628
|
*/
|
|
3532
3629
|
function () { return _this._bootstrapper.appBootstrapped$; })), filter((/**
|
|
3533
3630
|
* @param {?} appBootstrapped
|
|
3534
3631
|
* @return {?}
|
|
3535
3632
|
*/
|
|
3536
|
-
function (appBootstrapped) { return !!appBootstrapped; })),
|
|
3633
|
+
function (appBootstrapped) { return !!appBootstrapped; })), catchError((/**
|
|
3634
|
+
* @param {?} error
|
|
3635
|
+
* @return {?}
|
|
3636
|
+
*/
|
|
3637
|
+
function (error) {
|
|
3638
|
+
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
3639
|
+
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
3640
|
+
// break existing user's code or unit tests. We catch the error manually to
|
|
3641
|
+
// be backward compatible with the old behavior.
|
|
3642
|
+
_this._internalErrorReporter.reportErrorSafely(error);
|
|
3643
|
+
return EMPTY;
|
|
3644
|
+
})), takeUntil(this._destroy$))
|
|
3537
3645
|
.subscribe((/**
|
|
3538
3646
|
* @return {?}
|
|
3539
3647
|
*/
|
|
3540
|
-
function () { return _this.
|
|
3648
|
+
function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
|
|
3541
3649
|
};
|
|
3542
3650
|
/**
|
|
3543
|
-
* Invoke the init function on the states.
|
|
3544
|
-
*/
|
|
3545
|
-
/**
|
|
3546
|
-
* Invoke the init function on the states.
|
|
3547
3651
|
* @private
|
|
3548
3652
|
* @param {?} mappedStores
|
|
3549
3653
|
* @return {?}
|
|
3550
3654
|
*/
|
|
3551
|
-
LifecycleStateManager.prototype.
|
|
3552
|
-
* Invoke the init function on the states.
|
|
3655
|
+
LifecycleStateManager.prototype._invokeInitOnStates = /**
|
|
3553
3656
|
* @private
|
|
3554
3657
|
* @param {?} mappedStores
|
|
3555
3658
|
* @return {?}
|
|
@@ -3599,16 +3702,11 @@ var LifecycleStateManager = /** @class */ (function () {
|
|
|
3599
3702
|
}
|
|
3600
3703
|
};
|
|
3601
3704
|
/**
|
|
3602
|
-
* Invoke the bootstrap function on the states.
|
|
3603
|
-
*/
|
|
3604
|
-
/**
|
|
3605
|
-
* Invoke the bootstrap function on the states.
|
|
3606
3705
|
* @private
|
|
3607
3706
|
* @param {?} mappedStores
|
|
3608
3707
|
* @return {?}
|
|
3609
3708
|
*/
|
|
3610
|
-
LifecycleStateManager.prototype.
|
|
3611
|
-
* Invoke the bootstrap function on the states.
|
|
3709
|
+
LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
|
|
3612
3710
|
* @private
|
|
3613
3711
|
* @param {?} mappedStores
|
|
3614
3712
|
* @return {?}
|
|
@@ -3652,6 +3750,7 @@ var LifecycleStateManager = /** @class */ (function () {
|
|
|
3652
3750
|
/** @nocollapse */
|
|
3653
3751
|
LifecycleStateManager.ctorParameters = function () { return [
|
|
3654
3752
|
{ type: Store },
|
|
3753
|
+
{ type: InternalErrorReporter },
|
|
3655
3754
|
{ type: InternalStateOperations },
|
|
3656
3755
|
{ type: StateContextFactory },
|
|
3657
3756
|
{ type: NgxsBootstrapper }
|
|
@@ -3669,6 +3768,11 @@ if (false) {
|
|
|
3669
3768
|
* @private
|
|
3670
3769
|
*/
|
|
3671
3770
|
LifecycleStateManager.prototype._store;
|
|
3771
|
+
/**
|
|
3772
|
+
* @type {?}
|
|
3773
|
+
* @private
|
|
3774
|
+
*/
|
|
3775
|
+
LifecycleStateManager.prototype._internalErrorReporter;
|
|
3672
3776
|
/**
|
|
3673
3777
|
* @type {?}
|
|
3674
3778
|
* @private
|
|
@@ -4508,5 +4612,5 @@ if (false) {
|
|
|
4508
4612
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4509
4613
|
*/
|
|
4510
4614
|
|
|
4511
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq,
|
|
4615
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, InternalErrorReporter as ɵr, SelectFactory as ɵs, ensureStoreMetadata as ɵu, getStoreMetadata as ɵv, ensureSelectorMetadata as ɵw, getSelectorMetadata as ɵx, LifecycleStateManager as ɵy, NgxsFeatureModule as ɵz };
|
|
4512
4616
|
//# sourceMappingURL=ngxs-store.js.map
|