@ngxs/store 3.7.6-dev.master-7c829a7 → 3.7.6-dev.master-fb318b1

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.
@@ -2781,6 +2781,175 @@
2781
2781
  }
2782
2782
  }
2783
2783
 
2784
+ /**
2785
+ * @fileoverview added by tsickle
2786
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2787
+ */
2788
+ /**
2789
+ * Init action
2790
+ */
2791
+ var /**
2792
+ * Init action
2793
+ */
2794
+ InitState = /** @class */ (function () {
2795
+ function InitState() {
2796
+ }
2797
+ Object.defineProperty(InitState, "type", {
2798
+ get: /**
2799
+ * @return {?}
2800
+ */
2801
+ function () {
2802
+ // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
2803
+ return '@@INIT';
2804
+ },
2805
+ enumerable: true,
2806
+ configurable: true
2807
+ });
2808
+ return InitState;
2809
+ }());
2810
+ /**
2811
+ * Update action
2812
+ */
2813
+ var /**
2814
+ * Update action
2815
+ */
2816
+ UpdateState = /** @class */ (function () {
2817
+ function UpdateState(addedStates) {
2818
+ this.addedStates = addedStates;
2819
+ }
2820
+ Object.defineProperty(UpdateState, "type", {
2821
+ get: /**
2822
+ * @return {?}
2823
+ */
2824
+ function () {
2825
+ // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
2826
+ return '@@UPDATE_STATE';
2827
+ },
2828
+ enumerable: true,
2829
+ configurable: true
2830
+ });
2831
+ return UpdateState;
2832
+ }());
2833
+ if (false) {
2834
+ /** @type {?} */
2835
+ UpdateState.prototype.addedStates;
2836
+ }
2837
+
2838
+ /**
2839
+ * @fileoverview added by tsickle
2840
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2841
+ */
2842
+ /**
2843
+ * @record
2844
+ */
2845
+ function NgxsDevelopmentOptions() { }
2846
+ if (false) {
2847
+ /** @type {?} */
2848
+ NgxsDevelopmentOptions.prototype.warnOnUnhandledActions;
2849
+ }
2850
+ /** @type {?} */
2851
+ var NGXS_DEVELOPMENT_OPTIONS = new core.InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
2852
+ providedIn: 'root',
2853
+ factory: (/**
2854
+ * @return {?}
2855
+ */
2856
+ function () { return ({ warnOnUnhandledActions: true }); })
2857
+ });
2858
+
2859
+ /**
2860
+ * @fileoverview added by tsickle
2861
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2862
+ */
2863
+ var NgxsUnhandledActionsLogger = /** @class */ (function () {
2864
+ function NgxsUnhandledActionsLogger(options) {
2865
+ /**
2866
+ * These actions should be ignored by default; the user can increase this
2867
+ * list in the future via the `ignoreActions` method.
2868
+ */
2869
+ this._ignoredActions = new Set([InitState.type, UpdateState.type]);
2870
+ if (typeof options.warnOnUnhandledActions === 'object') {
2871
+ this.ignoreActions.apply(this, __spread(options.warnOnUnhandledActions.ignore));
2872
+ }
2873
+ }
2874
+ /**
2875
+ * Adds actions to the internal list of actions that should be ignored.
2876
+ */
2877
+ /**
2878
+ * Adds actions to the internal list of actions that should be ignored.
2879
+ * @param {...?} actions
2880
+ * @return {?}
2881
+ */
2882
+ NgxsUnhandledActionsLogger.prototype.ignoreActions = /**
2883
+ * Adds actions to the internal list of actions that should be ignored.
2884
+ * @param {...?} actions
2885
+ * @return {?}
2886
+ */
2887
+ function () {
2888
+ var actions = [];
2889
+ for (var _i = 0; _i < arguments.length; _i++) {
2890
+ actions[_i] = arguments[_i];
2891
+ }
2892
+ var e_1, _a;
2893
+ try {
2894
+ for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
2895
+ var action = actions_1_1.value;
2896
+ this._ignoredActions.add(action.type);
2897
+ }
2898
+ }
2899
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2900
+ finally {
2901
+ try {
2902
+ if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
2903
+ }
2904
+ finally { if (e_1) throw e_1.error; }
2905
+ }
2906
+ };
2907
+ /** @internal */
2908
+ /**
2909
+ * \@internal
2910
+ * @param {?} action
2911
+ * @return {?}
2912
+ */
2913
+ NgxsUnhandledActionsLogger.prototype.warn = /**
2914
+ * \@internal
2915
+ * @param {?} action
2916
+ * @return {?}
2917
+ */
2918
+ function (action) {
2919
+ /** @type {?} */
2920
+ var actionShouldBeIgnored = Array.from(this._ignoredActions).some((/**
2921
+ * @param {?} type
2922
+ * @return {?}
2923
+ */
2924
+ function (type) { return type === getActionTypeFromInstance(action); }));
2925
+ if (actionShouldBeIgnored) {
2926
+ return;
2927
+ }
2928
+ action =
2929
+ action.constructor && action.constructor.name !== 'Object'
2930
+ ? action.constructor.name
2931
+ : action.type;
2932
+ console.warn("The " + action + " action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.");
2933
+ };
2934
+ NgxsUnhandledActionsLogger.decorators = [
2935
+ { type: core.Injectable }
2936
+ ];
2937
+ /** @nocollapse */
2938
+ NgxsUnhandledActionsLogger.ctorParameters = function () { return [
2939
+ { type: undefined, decorators: [{ type: core.Inject, args: [NGXS_DEVELOPMENT_OPTIONS,] }] }
2940
+ ]; };
2941
+ return NgxsUnhandledActionsLogger;
2942
+ }());
2943
+ if (false) {
2944
+ /**
2945
+ * These actions should be ignored by default; the user can increase this
2946
+ * list in the future via the `ignoreActions` method.
2947
+ * @type {?}
2948
+ * @private
2949
+ */
2950
+ NgxsUnhandledActionsLogger.prototype._ignoredActions;
2951
+ }
2952
+
2784
2953
  /**
2785
2954
  * @fileoverview added by tsickle
2786
2955
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2926,10 +3095,8 @@
2926
3095
  * @return {?}
2927
3096
  */
2928
3097
  function () {
2929
- // I'm using non-null assertion here since `_actionsSubscrition` will
2930
- // be 100% defined. This is because `ngOnDestroy()` cannot be invoked
2931
- // on the `StateFactory` until its initialized :) An it's initialized
2932
- // for the first time along with the `NgxsRootModule`.
3098
+ // This is being non-null asserted since `_actionsSubscrition` is
3099
+ // initialized within the constructor.
2933
3100
  (/** @type {?} */ (this._actionsSubscription)).unsubscribe();
2934
3101
  };
2935
3102
  /**
@@ -3106,6 +3273,10 @@
3106
3273
  var type = (/** @type {?} */ (getActionTypeFromInstance(action)));
3107
3274
  /** @type {?} */
3108
3275
  var results = [];
3276
+ // Determines whether the dispatched action has been handled, this is assigned
3277
+ // to `true` within the below `for` loop if any `actionMetas` has been found.
3278
+ /** @type {?} */
3279
+ var actionHasBeenHandled = false;
3109
3280
  try {
3110
3281
  for (var _c = __values(this.states), _d = _c.next(); !_d.done; _d = _c.next()) {
3111
3282
  var metadata = _d.value;
@@ -3158,6 +3329,7 @@
3158
3329
  catch (e) {
3159
3330
  results.push(rxjs.throwError(e));
3160
3331
  }
3332
+ actionHasBeenHandled = true;
3161
3333
  }
3162
3334
  }
3163
3335
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -3177,6 +3349,18 @@
3177
3349
  }
3178
3350
  finally { if (e_2) throw e_2.error; }
3179
3351
  }
3352
+ // The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
3353
+ // only during development.
3354
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !actionHasBeenHandled) {
3355
+ /** @type {?} */
3356
+ var unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
3357
+ // The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
3358
+ // `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
3359
+ // didn't return `null` so we may ensure the module has been imported.
3360
+ if (unhandledActionsLogger) {
3361
+ unhandledActionsLogger.warn(action);
3362
+ }
3363
+ }
3180
3364
  if (!results.length) {
3181
3365
  results.push(rxjs.of({}));
3182
3366
  }
@@ -4057,60 +4241,6 @@
4057
4241
  SelectFactory.config;
4058
4242
  }
4059
4243
 
4060
- /**
4061
- * @fileoverview added by tsickle
4062
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4063
- */
4064
- /**
4065
- * Init action
4066
- */
4067
- var /**
4068
- * Init action
4069
- */
4070
- InitState = /** @class */ (function () {
4071
- function InitState() {
4072
- }
4073
- Object.defineProperty(InitState, "type", {
4074
- get: /**
4075
- * @return {?}
4076
- */
4077
- function () {
4078
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
4079
- return '@@INIT';
4080
- },
4081
- enumerable: true,
4082
- configurable: true
4083
- });
4084
- return InitState;
4085
- }());
4086
- /**
4087
- * Update action
4088
- */
4089
- var /**
4090
- * Update action
4091
- */
4092
- UpdateState = /** @class */ (function () {
4093
- function UpdateState(addedStates) {
4094
- this.addedStates = addedStates;
4095
- }
4096
- Object.defineProperty(UpdateState, "type", {
4097
- get: /**
4098
- * @return {?}
4099
- */
4100
- function () {
4101
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
4102
- return '@@UPDATE_STATE';
4103
- },
4104
- enumerable: true,
4105
- configurable: true
4106
- });
4107
- return UpdateState;
4108
- }());
4109
- if (false) {
4110
- /** @type {?} */
4111
- UpdateState.prototype.addedStates;
4112
- }
4113
-
4114
4244
  /**
4115
4245
  * @fileoverview added by tsickle
4116
4246
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4817,12 +4947,44 @@
4817
4947
  StateToken.prototype.name;
4818
4948
  }
4819
4949
 
4950
+ /**
4951
+ * @fileoverview added by tsickle
4952
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4953
+ */
4954
+ var NgxsDevelopmentModule = /** @class */ (function () {
4955
+ function NgxsDevelopmentModule() {
4956
+ }
4957
+ /**
4958
+ * @param {?} options
4959
+ * @return {?}
4960
+ */
4961
+ NgxsDevelopmentModule.forRoot = /**
4962
+ * @param {?} options
4963
+ * @return {?}
4964
+ */
4965
+ function (options) {
4966
+ return {
4967
+ ngModule: NgxsDevelopmentModule,
4968
+ providers: [
4969
+ NgxsUnhandledActionsLogger,
4970
+ { provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
4971
+ ]
4972
+ };
4973
+ };
4974
+ NgxsDevelopmentModule.decorators = [
4975
+ { type: core.NgModule }
4976
+ ];
4977
+ return NgxsDevelopmentModule;
4978
+ }());
4979
+
4820
4980
  exports.Action = Action;
4821
4981
  exports.Actions = Actions;
4822
4982
  exports.InitState = InitState;
4823
4983
  exports.NGXS_PLUGINS = NGXS_PLUGINS;
4984
+ exports.NgxsDevelopmentModule = NgxsDevelopmentModule;
4824
4985
  exports.NgxsModule = NgxsModule;
4825
4986
  exports.NgxsSimpleChange = NgxsSimpleChange;
4987
+ exports.NgxsUnhandledActionsLogger = NgxsUnhandledActionsLogger;
4826
4988
  exports.NoopNgxsExecutionStrategy = NoopNgxsExecutionStrategy;
4827
4989
  exports.Select = Select;
4828
4990
  exports.Selector = Selector;
@@ -4849,6 +5011,7 @@
4849
5011
  exports.setValue = setValue;
4850
5012
  exports.ɵa = OrderedSubject;
4851
5013
  exports.ɵb = InternalActions;
5014
+ exports.ɵba = NgxsFeatureModule;
4852
5015
  exports.ɵc = ROOT_STATE_TOKEN;
4853
5016
  exports.ɵd = FEATURE_STATE_TOKEN;
4854
5017
  exports.ɵe = SELECTOR_META_KEY;
@@ -4856,22 +5019,22 @@
4856
5019
  exports.ɵg = mergeDeep;
4857
5020
  exports.ɵh = USER_PROVIDED_NGXS_EXECUTION_STRATEGY;
4858
5021
  exports.ɵi = NGXS_EXECUTION_STRATEGY;
4859
- exports.ɵj = NgxsRootModule;
4860
- exports.ɵk = StateFactory;
4861
- exports.ɵl = InternalDispatchedActionResults;
4862
- exports.ɵm = InternalDispatcher;
4863
- exports.ɵn = StateContextFactory;
4864
- exports.ɵo = InternalStateOperations;
4865
- exports.ɵp = PluginManager;
4866
- exports.ɵq = InternalNgxsExecutionStrategy;
4867
- exports.ɵr = InternalErrorReporter;
4868
- exports.ɵs = SelectFactory;
4869
- exports.ɵu = ensureStoreMetadata;
4870
- exports.ɵv = getStoreMetadata;
4871
- exports.ɵw = ensureSelectorMetadata;
4872
- exports.ɵx = getSelectorMetadata;
4873
- exports.ɵy = LifecycleStateManager;
4874
- exports.ɵz = NgxsFeatureModule;
5022
+ exports.ɵj = NGXS_DEVELOPMENT_OPTIONS;
5023
+ exports.ɵk = NgxsRootModule;
5024
+ exports.ɵl = StateFactory;
5025
+ exports.ɵm = InternalDispatchedActionResults;
5026
+ exports.ɵn = InternalDispatcher;
5027
+ exports.ɵo = StateContextFactory;
5028
+ exports.ɵp = InternalStateOperations;
5029
+ exports.ɵq = PluginManager;
5030
+ exports.ɵr = InternalNgxsExecutionStrategy;
5031
+ exports.ɵs = InternalErrorReporter;
5032
+ exports.ɵt = SelectFactory;
5033
+ exports.ɵv = ensureStoreMetadata;
5034
+ exports.ɵw = getStoreMetadata;
5035
+ exports.ɵx = ensureSelectorMetadata;
5036
+ exports.ɵy = getSelectorMetadata;
5037
+ exports.ɵz = LifecycleStateManager;
4875
5038
 
4876
5039
  Object.defineProperty(exports, '__esModule', { value: true });
4877
5040