@ngxs/store 3.6.2 → 3.7.0

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.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/bundles/ngxs-store-operators.umd.js +36 -14
  3. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  4. package/bundles/ngxs-store-operators.umd.min.js +10 -10
  5. package/bundles/ngxs-store-operators.umd.min.js.map +1 -1
  6. package/bundles/ngxs-store.umd.js +76 -44
  7. package/bundles/ngxs-store.umd.js.map +1 -1
  8. package/bundles/ngxs-store.umd.min.js +11 -11
  9. package/bundles/ngxs-store.umd.min.js.map +1 -1
  10. package/esm2015/src/decorators/select/select.js +1 -2
  11. package/esm2015/src/decorators/select/symbols.js +1 -1
  12. package/esm2015/src/internal/dispatcher.js +9 -1
  13. package/esm2015/src/internal/internals.js +3 -3
  14. package/esm2015/src/internal/state-factory.js +12 -3
  15. package/esm2015/src/internal/state-operations.js +3 -3
  16. package/esm2015/src/ivy/ensure-state-class-is-injectable.js +3 -3
  17. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +6 -16
  18. package/esm2015/src/operators/of-action.js +6 -3
  19. package/esm2015/src/store.js +4 -4
  20. package/esm2015/src/utils/utils.js +4 -2
  21. package/esm5/src/decorators/select/select.js +1 -2
  22. package/esm5/src/decorators/select/symbols.js +1 -1
  23. package/esm5/src/internal/dispatcher.js +9 -1
  24. package/esm5/src/internal/internals.js +3 -3
  25. package/esm5/src/internal/state-factory.js +12 -3
  26. package/esm5/src/internal/state-operations.js +3 -3
  27. package/esm5/src/ivy/ensure-state-class-is-injectable.js +3 -3
  28. package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +6 -16
  29. package/esm5/src/operators/of-action.js +6 -3
  30. package/esm5/src/store.js +5 -5
  31. package/esm5/src/utils/utils.js +4 -2
  32. package/fesm2015/ngxs-store.js +39 -29
  33. package/fesm2015/ngxs-store.js.map +1 -1
  34. package/fesm5/ngxs-store.js +40 -30
  35. package/fesm5/ngxs-store.js.map +1 -1
  36. package/ngxs-store.metadata.json +1 -1
  37. package/package.json +3 -3
  38. package/src/decorators/select/select.d.ts +1 -2
  39. package/src/decorators/select/symbols.d.ts +0 -4
  40. package/src/internal/internals.d.ts +1 -1
  41. package/src/ivy/ivy-enabled-in-dev-mode.d.ts +2 -2
  42. package/src/operators/of-action.d.ts +9 -8
  43. package/src/store.d.ts +1 -1
@@ -5,18 +5,18 @@
5
5
  }(this, function (exports, core, internals, common, rxjs, operators) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation. All rights reserved.
9
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
- this file except in compliance with the License. You may obtain a copy of the
11
- License at http://www.apache.org/licenses/LICENSE-2.0
8
+ Copyright (c) Microsoft Corporation.
12
9
 
13
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
- MERCHANTABLITY OR NON-INFRINGEMENT.
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
17
12
 
18
- See the Apache Version 2.0 License for specific language governing permissions
19
- and limitations under the License.
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
20
  ***************************************************************************** */
21
21
  /* global Reflect, Promise */
22
22
 
@@ -72,10 +72,11 @@
72
72
  }
73
73
 
74
74
  function __awaiter(thisArg, _arguments, P, generator) {
75
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
75
76
  return new (P || (P = Promise))(function (resolve, reject) {
76
77
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
77
78
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
78
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
79
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
79
80
  step((generator = generator.apply(thisArg, _arguments || [])).next());
80
81
  });
81
82
  }
@@ -108,19 +109,25 @@
108
109
  }
109
110
  }
110
111
 
112
+ function __createBinding(o, m, k, k2) {
113
+ if (k2 === undefined) k2 = k;
114
+ o[k2] = m[k];
115
+ }
116
+
111
117
  function __exportStar(m, exports) {
112
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
118
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
113
119
  }
114
120
 
115
121
  function __values(o) {
116
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
122
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
117
123
  if (m) return m.call(o);
118
- return {
124
+ if (o && typeof o.length === "number") return {
119
125
  next: function () {
120
126
  if (o && i >= o.length) o = void 0;
121
127
  return { value: o && o[i++], done: !o };
122
128
  }
123
129
  };
130
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
124
131
  }
125
132
 
126
133
  function __read(o, n) {
@@ -199,6 +206,21 @@
199
206
 
200
207
  function __importDefault(mod) {
201
208
  return (mod && mod.__esModule) ? mod : { default: mod };
209
+ }
210
+
211
+ function __classPrivateFieldGet(receiver, privateMap) {
212
+ if (!privateMap.has(receiver)) {
213
+ throw new TypeError("attempted to get private field on non-instance");
214
+ }
215
+ return privateMap.get(receiver);
216
+ }
217
+
218
+ function __classPrivateFieldSet(receiver, privateMap, value) {
219
+ if (!privateMap.has(receiver)) {
220
+ throw new TypeError("attempted to set private field on non-instance");
221
+ }
222
+ privateMap.set(receiver, value);
223
+ return value;
202
224
  }
203
225
 
204
226
  var _a;
@@ -684,7 +706,9 @@
684
706
  if (action.constructor && action.constructor.type) {
685
707
  return action.constructor.type;
686
708
  }
687
- return action.type;
709
+ else {
710
+ return action.type;
711
+ }
688
712
  }
689
713
  /**
690
714
  * Matches a action
@@ -796,10 +820,10 @@
796
820
  */
797
821
  StateOperations.prototype.setState = function (val) { };
798
822
  /**
799
- * @param {?} actions
823
+ * @param {?} actionOrActions
800
824
  * @return {?}
801
825
  */
802
- StateOperations.prototype.dispatch = function (actions) { };
826
+ StateOperations.prototype.dispatch = function (actionOrActions) { };
803
827
  }
804
828
  /**
805
829
  * @record
@@ -1360,13 +1384,16 @@
1360
1384
  return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
1361
1385
  }
1362
1386
  /**
1363
- * @template T
1364
1387
  * @param {?} allowedTypes
1365
1388
  * @param {?=} statuses
1366
1389
  * @param {?=} mapOperator
1367
1390
  * @return {?}
1368
1391
  */
1369
- function ofActionOperator(allowedTypes, statuses, mapOperator) {
1392
+ function ofActionOperator(allowedTypes, statuses,
1393
+ // This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
1394
+ // since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
1395
+ // defaults to `any`, thus there is no sense from union type.
1396
+ mapOperator) {
1370
1397
  if (mapOperator === void 0) { mapOperator = mapAction; }
1371
1398
  /** @type {?} */
1372
1399
  var allowedMap = createAllowedActionTypesMap(allowedTypes);
@@ -1996,6 +2023,13 @@
1996
2023
  function (action) {
1997
2024
  var _this = this;
1998
2025
  /** @type {?} */
2026
+ var type = getActionTypeFromInstance(action);
2027
+ if (!type) {
2028
+ /** @type {?} */
2029
+ var error = new Error("This action doesn't have a type property: " + action.constructor.name);
2030
+ return rxjs.throwError(error);
2031
+ }
2032
+ /** @type {?} */
1999
2033
  var prevState = this._stateStream.getValue();
2000
2034
  /** @type {?} */
2001
2035
  var plugins = this._pluginManager.plugins;
@@ -2286,10 +2320,10 @@
2286
2320
  */
2287
2321
  function (newState) { return _this._stateStream.next(newState); }),
2288
2322
  dispatch: (/**
2289
- * @param {?} actions
2323
+ * @param {?} actionOrActions
2290
2324
  * @return {?}
2291
2325
  */
2292
- function (actions) { return _this._dispatcher.dispatch(actions); })
2326
+ function (actionOrActions) { return _this._dispatcher.dispatch(actionOrActions); })
2293
2327
  };
2294
2328
  if (this._config.developmentMode) {
2295
2329
  return this.ensureStateAndActionsAreImmutable(rootStateOperations);
@@ -2917,13 +2951,13 @@
2917
2951
  function (actions$, action) {
2918
2952
  var e_2, _a, e_3, _b;
2919
2953
  /** @type {?} */
2954
+ var type = (/** @type {?} */ (getActionTypeFromInstance(action)));
2955
+ /** @type {?} */
2920
2956
  var results = [];
2921
2957
  try {
2922
2958
  for (var _c = __values(this.states), _d = _c.next(); !_d.done; _d = _c.next()) {
2923
2959
  var metadata = _d.value;
2924
2960
  /** @type {?} */
2925
- var type = (/** @type {?} */ (getActionTypeFromInstance(action)));
2926
- /** @type {?} */
2927
2961
  var actionMetas = metadata.actions[type];
2928
2962
  if (actionMetas) {
2929
2963
  try {
@@ -2938,6 +2972,15 @@
2938
2972
  result = rxjs.from(result);
2939
2973
  }
2940
2974
  if (result instanceof rxjs.Observable) {
2975
+ // If this observable has been completed w/o emitting
2976
+ // any value then we wouldn't want to complete the whole chain
2977
+ // of actions. Since if any observable completes then
2978
+ // action will be canceled.
2979
+ // For instance if any action handler would've had such statement:
2980
+ // `handler(ctx) { return EMPTY; }`
2981
+ // then the action will be canceled.
2982
+ // See https://github.com/ngxs/store/issues/1568
2983
+ result = result.pipe(operators.defaultIfEmpty({}));
2941
2984
  if (actionMeta.options.cancelUncompleted) {
2942
2985
  // todo: ofActionDispatched should be used with action class
2943
2986
  result = result.pipe(operators.takeUntil(actions$.pipe(ofActionDispatched((/** @type {?} */ (action))))));
@@ -3551,16 +3594,16 @@
3551
3594
  */
3552
3595
  /**
3553
3596
  * Dispatches event(s).
3554
- * @param {?} event
3597
+ * @param {?} actionOrActions
3555
3598
  * @return {?}
3556
3599
  */
3557
3600
  Store.prototype.dispatch = /**
3558
3601
  * Dispatches event(s).
3559
- * @param {?} event
3602
+ * @param {?} actionOrActions
3560
3603
  * @return {?}
3561
3604
  */
3562
- function (event) {
3563
- return this._internalStateOperations.getRootStateOperations().dispatch(event);
3605
+ function (actionOrActions) {
3606
+ return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
3564
3607
  };
3565
3608
  /**
3566
3609
  * @param {?} selector
@@ -3835,12 +3878,8 @@
3835
3878
  * @fileoverview added by tsickle
3836
3879
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3837
3880
  */
3838
- /**
3839
- * Keep it as a single `const` variable since this `ReplaySubject`
3840
- * will be private and accessible only within this file.
3841
- * @type {?}
3842
- */
3843
- var _ivyEnabledInDevMode$ = new rxjs.ReplaySubject(1);
3881
+ /** @type {?} */
3882
+ var ivyEnabledInDevMode$ = new rxjs.ReplaySubject(1);
3844
3883
  /**
3845
3884
  * Ivy exposes helper functions to the global `window.ng` object.
3846
3885
  * Those functions are `getComponent, getContext,
@@ -3863,20 +3902,14 @@
3863
3902
  var _viewEngineEnabled = !!ng.probe && !!ng.coreTokens;
3864
3903
  /** @type {?} */
3865
3904
  var _ivyEnabledInDevMode = !_viewEngineEnabled && core.isDevMode();
3866
- _ivyEnabledInDevMode$.next(_ivyEnabledInDevMode);
3905
+ ivyEnabledInDevMode$.next(_ivyEnabledInDevMode);
3867
3906
  }
3868
3907
  catch (_a) {
3869
- _ivyEnabledInDevMode$.next(false);
3908
+ ivyEnabledInDevMode$.next(false);
3870
3909
  }
3871
3910
  finally {
3872
- _ivyEnabledInDevMode$.complete();
3911
+ ivyEnabledInDevMode$.complete();
3873
3912
  }
3874
- }
3875
- /**
3876
- * @return {?}
3877
- */
3878
- function ivyEnabledInDevMode() {
3879
- return _ivyEnabledInDevMode$.asObservable();
3880
3913
  }
3881
3914
 
3882
3915
  /**
@@ -4234,7 +4267,7 @@
4234
4267
  // AOT mode because this property is added before runtime. If an application is running in
4235
4268
  // JIT mode then this property can be added by the `@Injectable()` decorator. The `@Injectable()`
4236
4269
  // decorator has to go after the `@State()` decorator, thus we prevent users from unwanted DI errors.
4237
- ivyEnabledInDevMode().subscribe((/**
4270
+ ivyEnabledInDevMode$.subscribe((/**
4238
4271
  * @param {?} _ivyEnabledInDevMode
4239
4272
  * @return {?}
4240
4273
  */
@@ -4385,7 +4418,6 @@
4385
4418
  paths[_i - 1] = arguments[_i];
4386
4419
  }
4387
4420
  return (/**
4388
- * @template U, K
4389
4421
  * @param {?} target
4390
4422
  * @param {?} key
4391
4423
  * @return {?}