@ngxs/store 3.7.6-dev.master-94b06c2 → 3.7.6-dev.master-f234866

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.
@@ -1169,29 +1169,47 @@
1169
1169
  };
1170
1170
  }
1171
1171
 
1172
- var InternalNgxsExecutionStrategy = /** @class */ (function () {
1173
- function InternalNgxsExecutionStrategy(_executionStrategy) {
1174
- this._executionStrategy = _executionStrategy;
1175
- }
1176
- InternalNgxsExecutionStrategy.prototype.enter = function (func) {
1177
- return this._executionStrategy.enter(func);
1178
- };
1179
- InternalNgxsExecutionStrategy.prototype.leave = function (func) {
1180
- return this._executionStrategy.leave(func);
1172
+ /**
1173
+ * This wraps the provided function, and will enforce the following:
1174
+ * - The calls will execute in the order that they are made
1175
+ * - A call will only be initiated when the previous call has completed
1176
+ * - If there is a call currently executing then the new call will be added
1177
+ * to the queue and the function will return immediately
1178
+ *
1179
+ * NOTE: The following assumptions about the operation must hold true:
1180
+ * - The operation is synchronous in nature
1181
+ * - If any asynchronous side effects of the call exist, it should not
1182
+ * have any bearing on the correctness of the next call in the queue
1183
+ * - The operation has a void return
1184
+ * - The caller should not assume that the call has completed upon
1185
+ * return of the function
1186
+ * - The caller can assume that all the queued calls will complete
1187
+ * within the current microtask
1188
+ * - The only way that a call will encounter another call in the queue
1189
+ * would be if the call at the front of the queue initiated this call
1190
+ * as part of its synchronous execution
1191
+ */
1192
+ function orderedQueueOperation(operation) {
1193
+ var callsQueue = [];
1194
+ var busyPushingNext = false;
1195
+ return function callOperation() {
1196
+ var args = [];
1197
+ for (var _i = 0; _i < arguments.length; _i++) {
1198
+ args[_i] = arguments[_i];
1199
+ }
1200
+ if (busyPushingNext) {
1201
+ callsQueue.unshift(args);
1202
+ return;
1203
+ }
1204
+ busyPushingNext = true;
1205
+ operation.apply(void 0, __spreadArray([], __read(args)));
1206
+ while (callsQueue.length > 0) {
1207
+ var nextCallArgs = callsQueue.pop();
1208
+ nextCallArgs && operation.apply(void 0, __spreadArray([], __read(nextCallArgs)));
1209
+ }
1210
+ busyPushingNext = false;
1181
1211
  };
1182
- return InternalNgxsExecutionStrategy;
1183
- }());
1184
- /** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1185
- /** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy });
1186
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, decorators: [{
1187
- type: i0.Injectable
1188
- }], ctorParameters: function () {
1189
- return [{ type: undefined, decorators: [{
1190
- type: i0.Inject,
1191
- args: [NGXS_EXECUTION_STRATEGY]
1192
- }] }];
1193
- } });
1194
-
1212
+ }
1195
1213
  /**
1196
1214
  * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
1197
1215
  * A standard Subject does not have this guarantee.
@@ -1211,25 +1229,59 @@
1211
1229
  __extends(OrderedSubject, _super);
1212
1230
  function OrderedSubject() {
1213
1231
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1214
- _this._itemQueue = [];
1215
- _this._busyPushingNext = false;
1232
+ _this.next = orderedQueueOperation(function (value) { return _super.prototype.next.call(_this, value); });
1216
1233
  return _this;
1217
1234
  }
1218
- OrderedSubject.prototype.next = function (value) {
1219
- if (this._busyPushingNext) {
1220
- this._itemQueue.unshift(value);
1221
- return;
1222
- }
1223
- this._busyPushingNext = true;
1224
- _super.prototype.next.call(this, value);
1225
- while (this._itemQueue.length > 0) {
1226
- var nextValue = this._itemQueue.pop();
1227
- _super.prototype.next.call(this, nextValue);
1228
- }
1229
- this._busyPushingNext = false;
1230
- };
1231
1235
  return OrderedSubject;
1232
1236
  }(rxjs.Subject));
1237
+ /**
1238
+ * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
1239
+ * A standard BehaviorSubject does not have this guarantee.
1240
+ * For example, given the following code:
1241
+ * ```typescript
1242
+ * const subject = new BehaviorSubject<string>();
1243
+ subject.subscribe(value => {
1244
+ if (value === 'start') subject.next('end');
1245
+ });
1246
+ subject.subscribe(value => { });
1247
+ subject.next('start');
1248
+ * ```
1249
+ * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
1250
+ * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
1251
+ */
1252
+ var OrderedBehaviorSubject = /** @class */ (function (_super) {
1253
+ __extends(OrderedBehaviorSubject, _super);
1254
+ function OrderedBehaviorSubject() {
1255
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1256
+ _this.next = orderedQueueOperation(function (value) { return _super.prototype.next.call(_this, value); });
1257
+ return _this;
1258
+ }
1259
+ return OrderedBehaviorSubject;
1260
+ }(rxjs.BehaviorSubject));
1261
+
1262
+ var InternalNgxsExecutionStrategy = /** @class */ (function () {
1263
+ function InternalNgxsExecutionStrategy(_executionStrategy) {
1264
+ this._executionStrategy = _executionStrategy;
1265
+ }
1266
+ InternalNgxsExecutionStrategy.prototype.enter = function (func) {
1267
+ return this._executionStrategy.enter(func);
1268
+ };
1269
+ InternalNgxsExecutionStrategy.prototype.leave = function (func) {
1270
+ return this._executionStrategy.leave(func);
1271
+ };
1272
+ return InternalNgxsExecutionStrategy;
1273
+ }());
1274
+ /** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1275
+ /** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy });
1276
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, decorators: [{
1277
+ type: i0.Injectable
1278
+ }], ctorParameters: function () {
1279
+ return [{ type: undefined, decorators: [{
1280
+ type: i0.Inject,
1281
+ args: [NGXS_EXECUTION_STRATEGY]
1282
+ }] }];
1283
+ } });
1284
+
1233
1285
  /**
1234
1286
  * Internal Action stream that is emitted anytime an action is dispatched.
1235
1287
  */
@@ -1436,7 +1488,7 @@
1436
1488
  this.complete();
1437
1489
  };
1438
1490
  return StateStream;
1439
- }(rxjs.BehaviorSubject));
1491
+ }(OrderedBehaviorSubject));
1440
1492
  /** @nocollapse */ StateStream.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1441
1493
  /** @nocollapse */ StateStream.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream });
1442
1494
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream, decorators: [{
@@ -2157,7 +2209,7 @@
2157
2209
  * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
2158
2210
  * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
2159
2211
  */
2160
- this._selectableStateStream = this._stateStream.pipe(operators.observeOn(rxjs.queueScheduler), leaveNgxs(this._internalExecutionStrategy), operators.shareReplay({ bufferSize: 1, refCount: true }));
2212
+ this._selectableStateStream = this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy), operators.shareReplay({ bufferSize: 1, refCount: true }));
2161
2213
  this.initStateStream(initialStateValue);
2162
2214
  }
2163
2215
  /**