@dereekb/rxjs 13.4.0 → 13.4.2
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/index.cjs.js +225 -163
- package/index.esm.js +226 -164
- package/package.json +2 -2
- package/src/lib/filter/filter.map.d.ts +4 -0
- package/src/lib/filter/filter.source.d.ts +9 -3
- package/src/lib/iterator/iteration.accumulator.d.ts +21 -7
- package/src/lib/loading/loading.context.simple.d.ts +2 -0
- package/src/lib/loading/loading.context.state.d.ts +4 -0
- package/src/lib/loading/loading.state.d.ts +6 -0
- package/src/lib/loading/loading.state.rxjs.d.ts +2 -1
- package/src/lib/lock.d.ts +16 -4
- package/src/lib/object.d.ts +1 -1
- package/src/lib/rxjs/boolean.d.ts +6 -0
- package/src/lib/rxjs/expires.d.ts +7 -1
- package/src/lib/rxjs/getter.d.ts +7 -2
- package/src/lib/rxjs/misc.d.ts +1 -1
- package/src/lib/rxjs/model.d.ts +4 -0
- package/src/lib/rxjs/set.d.ts +4 -0
- package/src/lib/rxjs/value.d.ts +40 -4
- package/src/lib/subscription.d.ts +4 -0
- package/src/lib/work/work.factory.d.ts +2 -0
- package/src/lib/work/work.instance.d.ts +12 -3
package/index.cjs.js
CHANGED
|
@@ -45,6 +45,8 @@ function asObservableFromGetter(input, args) {
|
|
|
45
45
|
/**
|
|
46
46
|
* RxJS operator that flattens an emitted Maybe<{@link ObservableOrValueGetter}> into its resolved value,
|
|
47
47
|
* emitting `undefined` when the input is nullish.
|
|
48
|
+
*
|
|
49
|
+
* @returns an operator that unwraps Maybe<ObservableOrValueGetter> emissions, emitting undefined for nullish inputs
|
|
48
50
|
*/ function maybeValueFromObservableOrValueGetter() {
|
|
49
51
|
return rxjs.switchMap(function(x) {
|
|
50
52
|
return x != null ? asObservableFromGetter(x) : rxjs.of(undefined);
|
|
@@ -139,6 +141,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
139
141
|
*
|
|
140
142
|
* @param isCheckFunction - optional check function
|
|
141
143
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
144
|
+
* @returns a function that evaluates each value against the check function and returns it or undefined
|
|
142
145
|
*/ function makeReturnIfIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
143
146
|
return function(value) {
|
|
144
147
|
return returnIfIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
@@ -150,6 +153,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
150
153
|
* @param isCheckFunction - optional check function
|
|
151
154
|
* @param value - the value to check
|
|
152
155
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
156
|
+
* @returns an observable that emits the value if the check passes, or undefined otherwise
|
|
153
157
|
*/ function returnIfIs(isCheckFunction, value, defaultValueOnMaybe) {
|
|
154
158
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe).pipe(rxjs.map(function(x) {
|
|
155
159
|
return x ? value : undefined;
|
|
@@ -160,6 +164,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
160
164
|
*
|
|
161
165
|
* @param isCheckFunction - optional check function
|
|
162
166
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
167
|
+
* @returns a function that evaluates each value against the check function and returns an observable boolean
|
|
163
168
|
*/ function makeCheckIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
164
169
|
return function(value) {
|
|
165
170
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
@@ -173,6 +178,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
173
178
|
* @param isCheckFunction - optional check function
|
|
174
179
|
* @param value - the value to check
|
|
175
180
|
* @param defaultValueOnMaybe - default result for null/undefined values (defaults to false)
|
|
181
|
+
* @returns an observable boolean indicating whether the value passes the check
|
|
176
182
|
*/ function checkIs(isCheckFunction, value) {
|
|
177
183
|
var defaultValueOnMaybe = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
178
184
|
var is = isCheckFunction ? value != null ? isCheckFunction(value) : rxjs.of(defaultValueOnMaybe) : rxjs.of(true);
|
|
@@ -181,6 +187,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
181
187
|
// MARK: Filter
|
|
182
188
|
/**
|
|
183
189
|
* RxJS operator that filters out null and undefined values, only passing through defined values.
|
|
190
|
+
*
|
|
191
|
+
* @returns operator that filters out null and undefined emissions
|
|
184
192
|
*/ function filterMaybe() {
|
|
185
193
|
return rxjs.filter(util.isMaybeSo);
|
|
186
194
|
}
|
|
@@ -189,11 +197,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
189
197
|
*/ var filterMaybeStrict = filterMaybe;
|
|
190
198
|
/**
|
|
191
199
|
* RxJS operator that filters out null/undefined elements from an emitted array, keeping only defined values.
|
|
200
|
+
*
|
|
201
|
+
* @returns operator that maps each emitted array to a version with null/undefined elements removed
|
|
192
202
|
*/ function filterMaybeArray() {
|
|
193
203
|
return rxjs.map(util.filterMaybeArrayValues);
|
|
194
204
|
}
|
|
195
205
|
/**
|
|
196
206
|
* RxJS operator that skips all leading null/undefined emissions, then passes all subsequent values through.
|
|
207
|
+
*
|
|
208
|
+
* @returns operator that skips all null/undefined emissions at the start of the stream
|
|
197
209
|
*/ function skipAllInitialMaybe() {
|
|
198
210
|
return rxjs.skipWhile(function(x) {
|
|
199
211
|
return x == null;
|
|
@@ -201,6 +213,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
201
213
|
}
|
|
202
214
|
/**
|
|
203
215
|
* RxJS operator that skips only the first emission if it is null/undefined, then passes all subsequent values.
|
|
216
|
+
*
|
|
217
|
+
* @returns operator that skips the first null/undefined emission if it occurs at the start of the stream
|
|
204
218
|
*/ function skipInitialMaybe() {
|
|
205
219
|
return skipMaybes(1);
|
|
206
220
|
}
|
|
@@ -208,6 +222,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
208
222
|
* RxJS operator that skips up to `maxToSkip` null/undefined emissions, then passes all subsequent values.
|
|
209
223
|
*
|
|
210
224
|
* @param maxToSkip - maximum number of null/undefined emissions to skip
|
|
225
|
+
* @returns operator that skips the first N null/undefined emissions from the stream
|
|
211
226
|
*/ function skipMaybes(maxToSkip) {
|
|
212
227
|
return rxjs.skipWhile(function(x, i) {
|
|
213
228
|
return x == null && i < maxToSkip;
|
|
@@ -229,7 +244,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
229
244
|
});
|
|
230
245
|
}
|
|
231
246
|
function switchMapToDefault(defaultObs, useDefault) {
|
|
232
|
-
var useDefaultFn = useDefault ? useDefault : function(x) {
|
|
247
|
+
var useDefaultFn = useDefault !== null && useDefault !== void 0 ? useDefault : function(x) {
|
|
233
248
|
return rxjs.of(x == null);
|
|
234
249
|
};
|
|
235
250
|
return rxjs.switchMap(function(x) {
|
|
@@ -245,6 +260,9 @@ function switchMapToDefault(defaultObs, useDefault) {
|
|
|
245
260
|
/**
|
|
246
261
|
* RxJS operator that resolves an observable/getter config input into a value, applying defaults
|
|
247
262
|
* for `null`/`undefined`/`true` inputs and emitting `null` for `false`.
|
|
263
|
+
*
|
|
264
|
+
* @param config - configuration providing an optional default getter for null/undefined/true inputs
|
|
265
|
+
* @returns operator that resolves each emitted getter into a value, using the default for nullish or true inputs
|
|
248
266
|
*/ function switchMapObject(config) {
|
|
249
267
|
var defaultGetter = config.defaultGetter;
|
|
250
268
|
return rxjs.switchMap(function(inputConfig) {
|
|
@@ -279,6 +297,8 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
279
297
|
* RxJS operator that filters out null/undefined observables and then switches to the remaining ones.
|
|
280
298
|
*
|
|
281
299
|
* Combines {@link filterMaybe} and `switchMap` to only subscribe to non-nullish observables.
|
|
300
|
+
*
|
|
301
|
+
* @returns operator that filters nullish observables and subscribes to the non-nullish ones
|
|
282
302
|
*/ function switchMapFilterMaybe() {
|
|
283
303
|
return function(source) {
|
|
284
304
|
var subscriber = source.pipe(filterMaybe(), rxjs.switchMap(function(x) {
|
|
@@ -289,10 +309,12 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
289
309
|
}
|
|
290
310
|
/**
|
|
291
311
|
* RxJS operator that switches to the emitted observable if defined, or emits `undefined` when the observable is nullish.
|
|
312
|
+
*
|
|
313
|
+
* @returns operator that switches to the emitted observable or emits undefined for null/undefined inputs
|
|
292
314
|
*/ function switchMapMaybe() {
|
|
293
315
|
return function(source) {
|
|
294
316
|
var subscriber = source.pipe(rxjs.switchMap(function(x) {
|
|
295
|
-
return x
|
|
317
|
+
return x !== null && x !== void 0 ? x : rxjs.of(undefined);
|
|
296
318
|
}));
|
|
297
319
|
return subscriber;
|
|
298
320
|
};
|
|
@@ -317,11 +339,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
317
339
|
});
|
|
318
340
|
}
|
|
319
341
|
/**
|
|
320
|
-
* Combines
|
|
342
|
+
* Combines the source observable with another observable via `combineLatest`, then maps the pair to a result.
|
|
321
343
|
*
|
|
322
|
-
* @param combineObs
|
|
323
|
-
* @param mapFn
|
|
324
|
-
* @returns
|
|
344
|
+
* @param combineObs - the secondary observable to combine with the source
|
|
345
|
+
* @param mapFn - function that maps the source value and combined value to the output
|
|
346
|
+
* @returns operator that combines the source with `combineObs` and maps each pair using `mapFn`
|
|
325
347
|
*/ function combineLatestMapFrom(combineObs, mapFn) {
|
|
326
348
|
return function(obs) {
|
|
327
349
|
return rxjs.combineLatest([
|
|
@@ -337,6 +359,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
337
359
|
* Creates an observable that emits a starting value, then a second value after a delay.
|
|
338
360
|
*
|
|
339
361
|
* If the delay is not provided, or is falsy, then the second value is never emitted.
|
|
362
|
+
*
|
|
363
|
+
* @param startWith - the value to emit immediately
|
|
364
|
+
* @param endWith - the value to emit after the delay
|
|
365
|
+
* @param delayTime - optional delay in milliseconds before emitting the second value
|
|
366
|
+
* @returns an observable that emits `startWith` immediately and `endWith` after the delay (if provided)
|
|
340
367
|
*/ function emitDelayObs(startWith, endWith, delayTime) {
|
|
341
368
|
var obs = rxjs.of(startWith);
|
|
342
369
|
if (delayTime) {
|
|
@@ -346,6 +373,10 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
346
373
|
}
|
|
347
374
|
/**
|
|
348
375
|
* Emits a value after a given delay after every new emission.
|
|
376
|
+
*
|
|
377
|
+
* @param value - the value to emit after the delay
|
|
378
|
+
* @param delayTime - duration in milliseconds before emitting the value
|
|
379
|
+
* @returns operator that appends the given value after each source emission with the specified delay
|
|
349
380
|
*/ function emitAfterDelay(value, delayTime) {
|
|
350
381
|
return function(obs) {
|
|
351
382
|
return obs.pipe(rxjs.switchMap(function(x) {
|
|
@@ -388,7 +419,7 @@ function _array_like_to_array$a(arr, len) {
|
|
|
388
419
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
389
420
|
return arr2;
|
|
390
421
|
}
|
|
391
|
-
function _array_without_holes$
|
|
422
|
+
function _array_without_holes$6(arr) {
|
|
392
423
|
if (Array.isArray(arr)) return _array_like_to_array$a(arr);
|
|
393
424
|
}
|
|
394
425
|
function _class_call_check$8(instance, Constructor) {
|
|
@@ -422,14 +453,14 @@ function _define_property$c(obj, key, value) {
|
|
|
422
453
|
}
|
|
423
454
|
return obj;
|
|
424
455
|
}
|
|
425
|
-
function _iterable_to_array$
|
|
456
|
+
function _iterable_to_array$6(iter) {
|
|
426
457
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
427
458
|
}
|
|
428
|
-
function _non_iterable_spread$
|
|
459
|
+
function _non_iterable_spread$6() {
|
|
429
460
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
430
461
|
}
|
|
431
|
-
function _to_consumable_array$
|
|
432
|
-
return _array_without_holes$
|
|
462
|
+
function _to_consumable_array$6(arr) {
|
|
463
|
+
return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$6();
|
|
433
464
|
}
|
|
434
465
|
function _unsupported_iterable_to_array$a(o, minLen) {
|
|
435
466
|
if (!o) return;
|
|
@@ -469,6 +500,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
469
500
|
key: "hasSubscription",
|
|
470
501
|
get: /**
|
|
471
502
|
* Whether a subscription is currently being managed.
|
|
503
|
+
*
|
|
504
|
+
* @returns true if a subscription is currently active
|
|
472
505
|
*/ function get() {
|
|
473
506
|
return Boolean(this._subscription);
|
|
474
507
|
}
|
|
@@ -548,6 +581,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
548
581
|
key: "hasSubscription",
|
|
549
582
|
get: /**
|
|
550
583
|
* Whether any subscriptions are currently being managed.
|
|
584
|
+
*
|
|
585
|
+
* @returns true if one or more subscriptions are currently active
|
|
551
586
|
*/ function get() {
|
|
552
587
|
var _this__subscriptions;
|
|
553
588
|
return Boolean((_this__subscriptions = this._subscriptions) === null || _this__subscriptions === void 0 ? void 0 : _this__subscriptions.length);
|
|
@@ -580,7 +615,7 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
580
615
|
*/ key: "addSubs",
|
|
581
616
|
value: function addSubs(subs) {
|
|
582
617
|
var _this__subscriptions;
|
|
583
|
-
var nextSubscriptions = _to_consumable_array$
|
|
618
|
+
var nextSubscriptions = _to_consumable_array$6((_this__subscriptions = this._subscriptions) !== null && _this__subscriptions !== void 0 ? _this__subscriptions : []);
|
|
584
619
|
util.convertToArray(subs).forEach(function(sub) {
|
|
585
620
|
if (!nextSubscriptions.includes(sub)) {
|
|
586
621
|
nextSubscriptions.push(sub);
|
|
@@ -813,24 +848,23 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
813
848
|
key: "initFilterTakesPriority",
|
|
814
849
|
value: function initFilterTakesPriority() {
|
|
815
850
|
var _this = this;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
}
|
|
851
|
+
var _this__initialFilterSub, _subscription;
|
|
852
|
+
(_subscription = (_this__initialFilterSub = this._initialFilterSub).subscription) !== null && _subscription !== void 0 ? _subscription : _this__initialFilterSub.subscription = this._initialFilterTakesPriority.pipe(rxjs.switchMap(function(clearFilterOnInitialFilterPush) {
|
|
853
|
+
if (clearFilterOnInitialFilterPush) {
|
|
854
|
+
return _this._initialFilter.pipe(rxjs.switchMap(function(x) {
|
|
855
|
+
return x !== null && x !== void 0 ? x : rxjs.EMPTY;
|
|
856
|
+
}), filterMaybe(), rxjs.map(function() {
|
|
857
|
+
return true;
|
|
858
|
+
}), rxjs.skip(1) // skip the first emission
|
|
859
|
+
);
|
|
860
|
+
} else {
|
|
861
|
+
return rxjs.EMPTY;
|
|
862
|
+
}
|
|
863
|
+
}), rxjs.defaultIfEmpty(false)).subscribe(function(clear) {
|
|
864
|
+
if (clear) {
|
|
865
|
+
_this.resetFilter();
|
|
866
|
+
}
|
|
867
|
+
});
|
|
834
868
|
}
|
|
835
869
|
},
|
|
836
870
|
{
|
|
@@ -855,7 +889,7 @@ function _array_like_to_array$8(arr, len) {
|
|
|
855
889
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
856
890
|
return arr2;
|
|
857
891
|
}
|
|
858
|
-
function _array_without_holes$
|
|
892
|
+
function _array_without_holes$5(arr) {
|
|
859
893
|
if (Array.isArray(arr)) return _array_like_to_array$8(arr);
|
|
860
894
|
}
|
|
861
895
|
function _class_call_check$6(instance, Constructor) {
|
|
@@ -889,14 +923,14 @@ function _define_property$a(obj, key, value) {
|
|
|
889
923
|
}
|
|
890
924
|
return obj;
|
|
891
925
|
}
|
|
892
|
-
function _iterable_to_array$
|
|
926
|
+
function _iterable_to_array$5(iter) {
|
|
893
927
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
894
928
|
}
|
|
895
|
-
function _non_iterable_spread$
|
|
929
|
+
function _non_iterable_spread$5() {
|
|
896
930
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
897
931
|
}
|
|
898
|
-
function _to_consumable_array$
|
|
899
|
-
return _array_without_holes$
|
|
932
|
+
function _to_consumable_array$5(arr) {
|
|
933
|
+
return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$5();
|
|
900
934
|
}
|
|
901
935
|
function _unsupported_iterable_to_array$8(o, minLen) {
|
|
902
936
|
if (!o) return;
|
|
@@ -1055,6 +1089,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
1055
1089
|
{
|
|
1056
1090
|
/**
|
|
1057
1091
|
* Sets the default filter observable for this key.
|
|
1092
|
+
*
|
|
1093
|
+
* @param filterObs - the observable to use as the default filter for this key
|
|
1058
1094
|
*/ key: "initWithFilter",
|
|
1059
1095
|
value: function initWithFilter(filterObs) {
|
|
1060
1096
|
this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
|
|
@@ -1063,6 +1099,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
1063
1099
|
{
|
|
1064
1100
|
/**
|
|
1065
1101
|
* Connects a filter source, adding its filter observable to this key's merged filters.
|
|
1102
|
+
*
|
|
1103
|
+
* @param filterSource - the filter source whose filter$ will be added to this key's merged stream
|
|
1066
1104
|
*/ key: "connectWithSource",
|
|
1067
1105
|
value: function connectWithSource(filterSource) {
|
|
1068
1106
|
this.dbxFilterMap.addFilterObs(this.key, filterSource.filter$);
|
|
@@ -1080,7 +1118,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
|
|
|
1080
1118
|
_define_property$a(this, "_source", new FilterSourceInstance());
|
|
1081
1119
|
_define_property$a(this, "_obs", new rxjs.BehaviorSubject([]));
|
|
1082
1120
|
_define_property$a(this, "_obs$", this._obs.pipe(rxjs.switchMap(function(x) {
|
|
1083
|
-
return rxjs.merge.apply(void 0, _to_consumable_array$
|
|
1121
|
+
return rxjs.merge.apply(void 0, _to_consumable_array$5(x.map(function(y) {
|
|
1084
1122
|
return y.obs;
|
|
1085
1123
|
})));
|
|
1086
1124
|
}), rxjs.distinctUntilChanged()));
|
|
@@ -1121,7 +1159,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
|
|
|
1121
1159
|
var deleteOnComplete = obs.pipe(rxjs.finalize(function() {
|
|
1122
1160
|
_this._deleteFilterObs(i);
|
|
1123
1161
|
})).subscribe();
|
|
1124
|
-
var nextObs = _to_consumable_array$
|
|
1162
|
+
var nextObs = _to_consumable_array$5(currentObs).concat([
|
|
1125
1163
|
{
|
|
1126
1164
|
i: i,
|
|
1127
1165
|
obs: obs,
|
|
@@ -1498,18 +1536,10 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1498
1536
|
next: function next() {
|
|
1499
1537
|
return _async_to_generator$1(function() {
|
|
1500
1538
|
return _ts_generator$1(this, function(_state) {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
iteration.nextPage()
|
|
1506
|
-
];
|
|
1507
|
-
case 1:
|
|
1508
|
-
return [
|
|
1509
|
-
2,
|
|
1510
|
-
_state.sent()
|
|
1511
|
-
];
|
|
1512
|
-
}
|
|
1539
|
+
return [
|
|
1540
|
+
2,
|
|
1541
|
+
iteration.nextPage()
|
|
1542
|
+
];
|
|
1513
1543
|
});
|
|
1514
1544
|
})();
|
|
1515
1545
|
}
|
|
@@ -1528,17 +1558,17 @@ function _array_like_to_array$7(arr, len) {
|
|
|
1528
1558
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1529
1559
|
return arr2;
|
|
1530
1560
|
}
|
|
1531
|
-
function _array_without_holes$
|
|
1561
|
+
function _array_without_holes$4(arr) {
|
|
1532
1562
|
if (Array.isArray(arr)) return _array_like_to_array$7(arr);
|
|
1533
1563
|
}
|
|
1534
|
-
function _iterable_to_array$
|
|
1564
|
+
function _iterable_to_array$4(iter) {
|
|
1535
1565
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1536
1566
|
}
|
|
1537
|
-
function _non_iterable_spread$
|
|
1567
|
+
function _non_iterable_spread$4() {
|
|
1538
1568
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1539
1569
|
}
|
|
1540
|
-
function _to_consumable_array$
|
|
1541
|
-
return _array_without_holes$
|
|
1570
|
+
function _to_consumable_array$4(arr) {
|
|
1571
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$4();
|
|
1542
1572
|
}
|
|
1543
1573
|
function _unsupported_iterable_to_array$7(o, minLen) {
|
|
1544
1574
|
if (!o) return;
|
|
@@ -1564,7 +1594,7 @@ function scanIntoArray() {
|
|
|
1564
1594
|
return rxjs.scan(function(acc, next) {
|
|
1565
1595
|
if (next != null) {
|
|
1566
1596
|
if (immutable) {
|
|
1567
|
-
acc = acc.concat(next);
|
|
1597
|
+
acc = _to_consumable_array$4(acc).concat(_to_consumable_array$4(util.asArray(next)));
|
|
1568
1598
|
} else {
|
|
1569
1599
|
acc = util.pushItemOrArrayItemsIntoArray(acc, next);
|
|
1570
1600
|
}
|
|
@@ -1594,7 +1624,7 @@ function scanIntoArray() {
|
|
|
1594
1624
|
}
|
|
1595
1625
|
return acc;
|
|
1596
1626
|
}, seed !== null && seed !== void 0 ? seed : []), distinctUntilArrayLengthChanges(), rxjs.map(function(x) {
|
|
1597
|
-
return _to_consumable_array$
|
|
1627
|
+
return _to_consumable_array$4(x);
|
|
1598
1628
|
}), rxjs.shareReplay(1));
|
|
1599
1629
|
});
|
|
1600
1630
|
}
|
|
@@ -1684,7 +1714,7 @@ function scanIntoArray() {
|
|
|
1684
1714
|
if (!acc.fromMatch || requireConsecutive) {
|
|
1685
1715
|
fromMatch = isMatch(from, next);
|
|
1686
1716
|
value = next;
|
|
1687
|
-
} else
|
|
1717
|
+
} else {
|
|
1688
1718
|
value = acc.value;
|
|
1689
1719
|
}
|
|
1690
1720
|
}
|
|
@@ -1718,6 +1748,8 @@ function scanIntoArray() {
|
|
|
1718
1748
|
}
|
|
1719
1749
|
/**
|
|
1720
1750
|
* RxJS operator that negates each emitted boolean value.
|
|
1751
|
+
*
|
|
1752
|
+
* @returns operator that maps each boolean emission to its negated value
|
|
1721
1753
|
*/ function isNot() {
|
|
1722
1754
|
return rxjs.map(function(x) {
|
|
1723
1755
|
return !x;
|
|
@@ -1725,6 +1757,8 @@ function scanIntoArray() {
|
|
|
1725
1757
|
}
|
|
1726
1758
|
/**
|
|
1727
1759
|
* RxJS operator that only emits when a boolean stream transitions from `true` to `false`.
|
|
1760
|
+
*
|
|
1761
|
+
* @returns operator that filters to only true-to-false transition emissions
|
|
1728
1762
|
*/ function onTrueToFalse() {
|
|
1729
1763
|
return onMatchDelta({
|
|
1730
1764
|
from: true,
|
|
@@ -1734,6 +1768,8 @@ function scanIntoArray() {
|
|
|
1734
1768
|
}
|
|
1735
1769
|
/**
|
|
1736
1770
|
* RxJS operator that only emits when a boolean stream transitions from `false` to `true`.
|
|
1771
|
+
*
|
|
1772
|
+
* @returns operator that filters to only false-to-true transition emissions
|
|
1737
1773
|
*/ function onFalseToTrue() {
|
|
1738
1774
|
return onMatchDelta({
|
|
1739
1775
|
from: false,
|
|
@@ -1806,7 +1842,7 @@ function scanIntoArray() {
|
|
|
1806
1842
|
* time relative to the current moment.
|
|
1807
1843
|
*
|
|
1808
1844
|
* @param expiresIn - duration in milliseconds until expiration
|
|
1809
|
-
* @returns an
|
|
1845
|
+
* @returns an `OperatorFunction` that maps each emission to an {@link Expires} object
|
|
1810
1846
|
*/ function toExpiration(expiresIn) {
|
|
1811
1847
|
return rxjs.map(function() {
|
|
1812
1848
|
var now = new Date();
|
|
@@ -1821,6 +1857,8 @@ function scanIntoArray() {
|
|
|
1821
1857
|
}
|
|
1822
1858
|
/**
|
|
1823
1859
|
* RxJS operator that filters out emissions whose {@link Expires} value has already expired.
|
|
1860
|
+
*
|
|
1861
|
+
* @returns operator that only passes through non-expired emissions
|
|
1824
1862
|
*/ function skipExpired() {
|
|
1825
1863
|
return rxjs.filter(function(expires) {
|
|
1826
1864
|
return !util.expirationDetails({
|
|
@@ -1832,6 +1870,7 @@ function scanIntoArray() {
|
|
|
1832
1870
|
* RxJS operator that skips emissions until the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1833
1871
|
*
|
|
1834
1872
|
* @param expiresIn - duration in milliseconds
|
|
1873
|
+
* @returns operator that skips emissions until the time window has elapsed
|
|
1835
1874
|
*/ function skipUntilExpiration(expiresIn) {
|
|
1836
1875
|
return rxjs.filter(function(x) {
|
|
1837
1876
|
return util.expirationDetails({
|
|
@@ -1844,6 +1883,7 @@ function scanIntoArray() {
|
|
|
1844
1883
|
* RxJS operator that skips emissions after the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1845
1884
|
*
|
|
1846
1885
|
* @param expiresIn - duration in milliseconds
|
|
1886
|
+
* @returns operator that passes through emissions only within the time window
|
|
1847
1887
|
*/ function skipAfterExpiration(expiresIn) {
|
|
1848
1888
|
return rxjs.filter(function(x) {
|
|
1849
1889
|
return !util.expirationDetails({
|
|
@@ -1857,6 +1897,7 @@ function scanIntoArray() {
|
|
|
1857
1897
|
*
|
|
1858
1898
|
* @param watch - observable whose emissions reset the time window
|
|
1859
1899
|
* @param takeFor - duration in milliseconds of each time window
|
|
1900
|
+
* @returns operator that limits source emissions to the active time window after each watch emission
|
|
1860
1901
|
*/ function skipUntilTimeElapsedAfterLastEmission(watch, takeFor) {
|
|
1861
1902
|
return function(observable) {
|
|
1862
1903
|
return watch.pipe(rxjs.switchMap(function() {
|
|
@@ -1876,6 +1917,7 @@ function scanIntoArray() {
|
|
|
1876
1917
|
*
|
|
1877
1918
|
* @param watch - observable whose emissions reset the skip window
|
|
1878
1919
|
* @param skipFor - duration in milliseconds to skip after each watch emission
|
|
1920
|
+
* @returns an operator that delays passing values through until time has elapsed since the last watch emission
|
|
1879
1921
|
*/ function takeAfterTimeElapsedSinceLastEmission(watch, skipFor) {
|
|
1880
1922
|
return function(observable) {
|
|
1881
1923
|
return watch.pipe(rxjs.switchMap(function() {
|
|
@@ -2027,7 +2069,7 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
|
2027
2069
|
return result;
|
|
2028
2070
|
}), rxjs.finalize(function() {
|
|
2029
2071
|
if (currentInstance) {
|
|
2030
|
-
destroy(currentInstance);
|
|
2072
|
+
void destroy(currentInstance);
|
|
2031
2073
|
}
|
|
2032
2074
|
}));
|
|
2033
2075
|
};
|
|
@@ -2103,6 +2145,8 @@ function tapLog(messageOrFunction) {
|
|
|
2103
2145
|
|
|
2104
2146
|
/**
|
|
2105
2147
|
* `distinctUntilChanged` variant that only emits when the model's `id` property changes.
|
|
2148
|
+
*
|
|
2149
|
+
* @returns operator that suppresses consecutive emissions with the same model `id`
|
|
2106
2150
|
*/ function distinctUntilModelIdChange() {
|
|
2107
2151
|
return distinctUntilObjectKeyChange(function(x) {
|
|
2108
2152
|
return x.id;
|
|
@@ -2110,6 +2154,8 @@ function tapLog(messageOrFunction) {
|
|
|
2110
2154
|
}
|
|
2111
2155
|
/**
|
|
2112
2156
|
* `distinctUntilChanged` variant that only emits when the model's `key` property changes.
|
|
2157
|
+
*
|
|
2158
|
+
* @returns operator that suppresses consecutive emissions with the same model `key`
|
|
2113
2159
|
*/ function distinctUntilModelKeyChange() {
|
|
2114
2160
|
return distinctUntilObjectKeyChange(function(x) {
|
|
2115
2161
|
return x.key;
|
|
@@ -2425,6 +2471,12 @@ function _array_like_to_array$5(arr, len) {
|
|
|
2425
2471
|
function _array_with_holes$2(arr) {
|
|
2426
2472
|
if (Array.isArray(arr)) return arr;
|
|
2427
2473
|
}
|
|
2474
|
+
function _array_without_holes$3(arr) {
|
|
2475
|
+
if (Array.isArray(arr)) return _array_like_to_array$5(arr);
|
|
2476
|
+
}
|
|
2477
|
+
function _iterable_to_array$3(iter) {
|
|
2478
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2479
|
+
}
|
|
2428
2480
|
function _iterable_to_array_limit$2(arr, i) {
|
|
2429
2481
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2430
2482
|
if (_i == null) return;
|
|
@@ -2452,9 +2504,15 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
2452
2504
|
function _non_iterable_rest$2() {
|
|
2453
2505
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2454
2506
|
}
|
|
2507
|
+
function _non_iterable_spread$3() {
|
|
2508
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2509
|
+
}
|
|
2455
2510
|
function _sliced_to_array$2(arr, i) {
|
|
2456
2511
|
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$2();
|
|
2457
2512
|
}
|
|
2513
|
+
function _to_consumable_array$3(arr) {
|
|
2514
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$3();
|
|
2515
|
+
}
|
|
2458
2516
|
function _unsupported_iterable_to_array$5(o, minLen) {
|
|
2459
2517
|
if (!o) return;
|
|
2460
2518
|
if (typeof o === "string") return _array_like_to_array$5(o, minLen);
|
|
@@ -2472,7 +2530,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2472
2530
|
*/ function combineLatestFromMapValuesObsFn(mapToObs) {
|
|
2473
2531
|
var combineArrayFn = combineLatestFromArrayObsFn(mapToObs);
|
|
2474
2532
|
return function(latestMap) {
|
|
2475
|
-
var mapValues =
|
|
2533
|
+
var mapValues = _to_consumable_array$3(latestMap).map(function(y) {
|
|
2476
2534
|
return y[1];
|
|
2477
2535
|
});
|
|
2478
2536
|
return combineArrayFn(mapValues);
|
|
@@ -2565,7 +2623,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2565
2623
|
*/ function errorOnEmissionsInPeriod(config) {
|
|
2566
2624
|
var _config_period = config.period, period = _config_period === void 0 ? 1000 : _config_period, maxEmissionsPerPeriod = config.maxEmissionsPerPeriod, onError = config.onError, inputErrorFactory = config.errorFactory, inputErrorMessage = config.errorMessage, switchToObs = config.switchToObs;
|
|
2567
2625
|
var errorMessage = inputErrorMessage !== null && inputErrorMessage !== void 0 ? inputErrorMessage : 'errorOnEmissionsInPeriod(): Too many emissions in time period.';
|
|
2568
|
-
var errorFactory = inputErrorFactory ? inputErrorFactory : !switchToObs ? function() {
|
|
2626
|
+
var errorFactory = inputErrorFactory !== null && inputErrorFactory !== void 0 ? inputErrorFactory : !switchToObs ? function() {
|
|
2569
2627
|
return new Error(errorMessage);
|
|
2570
2628
|
} : undefined;
|
|
2571
2629
|
return function(source) {
|
|
@@ -2625,6 +2683,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2625
2683
|
}
|
|
2626
2684
|
/**
|
|
2627
2685
|
* `distinctUntilChanged` variant for iterables that only emits when the contained values change.
|
|
2686
|
+
*
|
|
2687
|
+
* @returns operator that suppresses consecutive iterable emissions with the same set of values
|
|
2628
2688
|
*/ function distinctUntilHasDifferentValues() {
|
|
2629
2689
|
return rxjs.distinctUntilChanged(util.hasSameValues);
|
|
2630
2690
|
}
|
|
@@ -2878,7 +2938,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2878
2938
|
if (loading === true) {
|
|
2879
2939
|
result = false;
|
|
2880
2940
|
} else {
|
|
2881
|
-
|
|
2941
|
+
var _state_value;
|
|
2942
|
+
result = loading === false || Boolean((_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : state.error) || state.value === null;
|
|
2882
2943
|
}
|
|
2883
2944
|
}
|
|
2884
2945
|
return result;
|
|
@@ -2894,6 +2955,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2894
2955
|
* // { loading: false }
|
|
2895
2956
|
* loadingStateType(state); // LoadingStateType.IDLE
|
|
2896
2957
|
* ```
|
|
2958
|
+
*
|
|
2959
|
+
* @returns a loading state with `loading: false` and no value or error
|
|
2897
2960
|
*/ function idleLoadingState() {
|
|
2898
2961
|
return {
|
|
2899
2962
|
loading: false
|
|
@@ -3018,8 +3081,7 @@ function beginLoading(state) {
|
|
|
3018
3081
|
*/ function isLoadingStateWithStateType(type) {
|
|
3019
3082
|
var defaultResult = type === exports.LoadingStateType.IDLE ? true : false;
|
|
3020
3083
|
return function(state) {
|
|
3021
|
-
|
|
3022
|
-
return result;
|
|
3084
|
+
return state ? loadingStateType(state) === type : defaultResult;
|
|
3023
3085
|
};
|
|
3024
3086
|
}
|
|
3025
3087
|
/**
|
|
@@ -3062,8 +3124,7 @@ function beginLoading(state) {
|
|
|
3062
3124
|
* @param state - the loading state to check
|
|
3063
3125
|
* @returns true if the state has a defined (non-undefined) value
|
|
3064
3126
|
*/ function isLoadingStateWithDefinedValue(state) {
|
|
3065
|
-
|
|
3066
|
-
return result;
|
|
3127
|
+
return state ? state.value !== undefined : false;
|
|
3067
3128
|
}
|
|
3068
3129
|
/**
|
|
3069
3130
|
* Type guard that checks whether a {@link LoadingState} has a non-null error, regardless of loading status.
|
|
@@ -3077,8 +3138,7 @@ function beginLoading(state) {
|
|
|
3077
3138
|
* @param state - the loading state to check
|
|
3078
3139
|
* @returns true if the state has an error
|
|
3079
3140
|
*/ function isLoadingStateWithError(state) {
|
|
3080
|
-
|
|
3081
|
-
return result;
|
|
3141
|
+
return state ? state.error != null : false;
|
|
3082
3142
|
}
|
|
3083
3143
|
/**
|
|
3084
3144
|
* Type guard that checks whether a {@link LoadingState} has finished loading and has a defined value.
|
|
@@ -3086,8 +3146,7 @@ function beginLoading(state) {
|
|
|
3086
3146
|
* @param state - the loading state to check
|
|
3087
3147
|
* @returns true if finished loading with a non-undefined value
|
|
3088
3148
|
*/ function isLoadingStateFinishedLoadingWithDefinedValue(state) {
|
|
3089
|
-
|
|
3090
|
-
return result;
|
|
3149
|
+
return state ? isLoadingStateFinishedLoading(state) && state.value !== undefined : false;
|
|
3091
3150
|
}
|
|
3092
3151
|
/**
|
|
3093
3152
|
* Type guard that checks whether a {@link LoadingState} has finished loading and has an error.
|
|
@@ -3095,8 +3154,7 @@ function beginLoading(state) {
|
|
|
3095
3154
|
* @param state - the loading state to check
|
|
3096
3155
|
* @returns true if finished loading with an error
|
|
3097
3156
|
*/ function isLoadingStateFinishedLoadingWithError(state) {
|
|
3098
|
-
|
|
3099
|
-
return result;
|
|
3157
|
+
return state ? isLoadingStateFinishedLoading(state) && state.error != null : false;
|
|
3100
3158
|
}
|
|
3101
3159
|
/**
|
|
3102
3160
|
* Compares the metadata (page, loading, error) of two {@link PageLoadingState} instances for equivalence.
|
|
@@ -3122,12 +3180,13 @@ function beginLoading(state) {
|
|
|
3122
3180
|
*/ function isPageLoadingStateMetadataEqual(a, b) {
|
|
3123
3181
|
return util.valuesAreBothNullishOrEquivalent(a.page, b.page) && a.loading == b.loading && util.valuesAreBothNullishOrEquivalent(a.error, b.error);
|
|
3124
3182
|
}
|
|
3183
|
+
// eslint-disable-next-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
|
|
3125
3184
|
function mergeLoadingStates() {
|
|
3126
3185
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
3127
3186
|
args[_key] = arguments[_key];
|
|
3128
3187
|
}
|
|
3129
3188
|
var _loadingStates_find;
|
|
3130
|
-
var validArgs = util.filterMaybeArrayValues(args); // filter out any undefined values
|
|
3189
|
+
/* eslint-enable @typescript-eslint/max-params */ var validArgs = util.filterMaybeArrayValues(args); // filter out any undefined values
|
|
3131
3190
|
var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
|
|
3132
3191
|
var loadingStates = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
|
|
3133
3192
|
var mergeFn = lastValueIsMergeFn ? args[validArgs.length - 1] : function() {
|
|
@@ -3143,7 +3202,7 @@ function mergeLoadingStates() {
|
|
|
3143
3202
|
if (error) {
|
|
3144
3203
|
// ignore all loading states, except for any error-prone item that is still loading
|
|
3145
3204
|
var currentLoadings = loadingStates.map(function(x) {
|
|
3146
|
-
return
|
|
3205
|
+
return x.error ? x.loading : false;
|
|
3147
3206
|
});
|
|
3148
3207
|
var nonMaybeLoadings = currentLoadings.filter(function(x) {
|
|
3149
3208
|
return x != null;
|
|
@@ -3229,10 +3288,10 @@ function mergeLoadingStates() {
|
|
|
3229
3288
|
var mapValues = config.mapValues, mapState = config.mapState;
|
|
3230
3289
|
var loading = isAnyLoadingStateInLoadingState(input);
|
|
3231
3290
|
var error = input.map(function(x) {
|
|
3232
|
-
return x
|
|
3233
|
-
}).
|
|
3291
|
+
return x.error;
|
|
3292
|
+
}).find(function(x) {
|
|
3234
3293
|
return Boolean(x);
|
|
3235
|
-
})
|
|
3294
|
+
});
|
|
3236
3295
|
var result;
|
|
3237
3296
|
if (!error && !loading) {
|
|
3238
3297
|
if (mapValues) {
|
|
@@ -3254,7 +3313,7 @@ function mergeLoadingStates() {
|
|
|
3254
3313
|
}
|
|
3255
3314
|
function mapLoadingStateResults(input, config) {
|
|
3256
3315
|
var mapValue = config.mapValue, mapState = config.mapState, _config_alwaysMapValue = config.alwaysMapValue, alwaysMapValue = _config_alwaysMapValue === void 0 ? false : _config_alwaysMapValue;
|
|
3257
|
-
var inputValue = input
|
|
3316
|
+
var inputValue = input.value;
|
|
3258
3317
|
var value;
|
|
3259
3318
|
if ((inputValue != null || alwaysMapValue) && mapValue) {
|
|
3260
3319
|
value = mapValue(inputValue, input);
|
|
@@ -3390,28 +3449,23 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
3390
3449
|
return rxjs.of(errorResult(error));
|
|
3391
3450
|
}), timeoutStartWith(beginLoading(), 50), rxjs.shareReplay(1));
|
|
3392
3451
|
}
|
|
3452
|
+
// eslint-disable-next-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
|
|
3393
3453
|
function combineLoadingStates() {
|
|
3394
3454
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
3395
3455
|
args[_key] = arguments[_key];
|
|
3396
3456
|
}
|
|
3397
|
-
var validArgs = util.filterMaybeArrayValues(args); // filter out any undefined values
|
|
3457
|
+
/* eslint-enable @typescript-eslint/max-params */ var validArgs = util.filterMaybeArrayValues(args); // filter out any undefined values
|
|
3398
3458
|
var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
|
|
3399
3459
|
var obsArgs = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
|
|
3400
3460
|
var mergeFn = lastValueIsMergeFn ? validArgs[validArgs.length - 1] : undefined;
|
|
3401
3461
|
return rxjs.combineLatest(obsArgs).pipe(rxjs.distinctUntilChanged(function(x, y) {
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
}) === -1;
|
|
3406
|
-
return hasSameValues;
|
|
3407
|
-
} else {
|
|
3408
|
-
return x === y;
|
|
3409
|
-
}
|
|
3462
|
+
return !x.some(function(_, i) {
|
|
3463
|
+
return x[i] !== y[i];
|
|
3464
|
+
});
|
|
3410
3465
|
}), rxjs.map(function(states) {
|
|
3411
|
-
|
|
3466
|
+
return mergeLoadingStates.apply(void 0, _to_consumable_array$1(states).concat([
|
|
3412
3467
|
mergeFn
|
|
3413
3468
|
]));
|
|
3414
|
-
return result;
|
|
3415
3469
|
}), rxjs.shareReplay(1) // Share the result.
|
|
3416
3470
|
);
|
|
3417
3471
|
}
|
|
@@ -3446,7 +3500,7 @@ function combineLoadingStates() {
|
|
|
3446
3500
|
if (firstErrorState) {
|
|
3447
3501
|
result = errorResult(firstErrorState.error);
|
|
3448
3502
|
} else {
|
|
3449
|
-
var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.
|
|
3503
|
+
var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.some(isLoadingStateLoading);
|
|
3450
3504
|
if (oneOrMoreStatesAreCurrentlyLoading) {
|
|
3451
3505
|
result = beginLoading(); // still loading
|
|
3452
3506
|
} else {
|
|
@@ -3574,7 +3628,7 @@ function tapOnLoadingStateType(fn, type) {
|
|
|
3574
3628
|
};
|
|
3575
3629
|
}
|
|
3576
3630
|
return rxjs.tap(function(state) {
|
|
3577
|
-
if (
|
|
3631
|
+
if (decisionFunction(state)) {
|
|
3578
3632
|
fn(state);
|
|
3579
3633
|
}
|
|
3580
3634
|
});
|
|
@@ -3726,6 +3780,10 @@ function distinctLoadingState(inputConfig) {
|
|
|
3726
3780
|
*
|
|
3727
3781
|
* Determines the `loading` flag based on whether an error is present, whether the value is defined,
|
|
3728
3782
|
* and the `showLoadingOnUndefinedValue` setting. Loading progress is only included while loading.
|
|
3783
|
+
*
|
|
3784
|
+
* @param state - the current loading state to convert into a context event
|
|
3785
|
+
* @param input - configuration input controlling how the loading flag is derived
|
|
3786
|
+
* @returns a loading state context event derived from the given state
|
|
3729
3787
|
*/ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION(state, input) {
|
|
3730
3788
|
var showLoadingOnUndefinedValue = input.showLoadingOnUndefinedValue;
|
|
3731
3789
|
var error = state.error, value = state.value, loadingProgress = state.loadingProgress;
|
|
@@ -3796,7 +3854,7 @@ function distinctLoadingState(inputConfig) {
|
|
|
3796
3854
|
return result;
|
|
3797
3855
|
}), rxjs.distinctUntilChanged(isLoadingStateEqual), rxjs.shareReplay(1));
|
|
3798
3856
|
var currentState$ = currentStateStream$.pipe(rxjs.switchMap(function(x) {
|
|
3799
|
-
return x ? x : rxjs.of(undefined);
|
|
3857
|
+
return x !== null && x !== void 0 ? x : rxjs.of(undefined);
|
|
3800
3858
|
}));
|
|
3801
3859
|
var state$ = currentState$.pipe(filterMaybe(), rxjs.shareReplay(1));
|
|
3802
3860
|
var loading$ = eventStream$.pipe(rxjs.map(isLoadingStateLoading));
|
|
@@ -3840,7 +3898,8 @@ function distinctLoadingState(inputConfig) {
|
|
|
3840
3898
|
* @param listLoadingState - the list loading state to check
|
|
3841
3899
|
* @returns true if the value is empty or absent
|
|
3842
3900
|
*/ function isListLoadingStateWithEmptyValue(listLoadingState) {
|
|
3843
|
-
|
|
3901
|
+
var _listLoadingState_value;
|
|
3902
|
+
return Boolean(!((_listLoadingState_value = listLoadingState.value) === null || _listLoadingState_value === void 0 ? void 0 : _listLoadingState_value.length));
|
|
3844
3903
|
}
|
|
3845
3904
|
/**
|
|
3846
3905
|
* RxJS operator that maps each emitted {@link ListLoadingState} to a boolean indicating whether the list is empty.
|
|
@@ -4122,6 +4181,8 @@ function _object_spread_props$3(target, source) {
|
|
|
4122
4181
|
{
|
|
4123
4182
|
/**
|
|
4124
4183
|
* Whether the current state has a non-null error.
|
|
4184
|
+
*
|
|
4185
|
+
* @returns true if the current state contains an error
|
|
4125
4186
|
*/ key: "hasError",
|
|
4126
4187
|
value: function hasError() {
|
|
4127
4188
|
return isLoadingStateWithError(this._subject.value);
|
|
@@ -4614,55 +4675,48 @@ function itemAccumulator(itemIteration, inputMapItem) {
|
|
|
4614
4675
|
return rxjs.from(util.asPromise(countResults(allItems)));
|
|
4615
4676
|
})).subscribe({
|
|
4616
4677
|
next: function next(currentResultsCount) {
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
result = _state.sent();
|
|
4633
|
-
currentResultsCount = result.currentCount;
|
|
4634
|
-
return [
|
|
4635
|
-
2,
|
|
4636
|
-
result.shouldContinue
|
|
4637
|
-
];
|
|
4638
|
-
}
|
|
4639
|
-
});
|
|
4640
|
-
})();
|
|
4641
|
-
},
|
|
4642
|
-
next: function next() {
|
|
4643
|
-
return _async_to_generator(function() {
|
|
4644
|
-
return _ts_generator(this, function(_state) {
|
|
4678
|
+
util.performTaskLoop({
|
|
4679
|
+
initValue: currentResultsCount,
|
|
4680
|
+
checkContinue: function checkContinue(_x, _i) {
|
|
4681
|
+
return _async_to_generator(function() {
|
|
4682
|
+
var result;
|
|
4683
|
+
return _ts_generator(this, function(_state) {
|
|
4684
|
+
switch(_state.label){
|
|
4685
|
+
case 0:
|
|
4686
|
+
return [
|
|
4687
|
+
4,
|
|
4688
|
+
checkResultsLimit()
|
|
4689
|
+
];
|
|
4690
|
+
case 1:
|
|
4691
|
+
result = _state.sent();
|
|
4692
|
+
currentResultsCount = result.currentCount;
|
|
4645
4693
|
return [
|
|
4646
4694
|
2,
|
|
4647
|
-
|
|
4695
|
+
result.shouldContinue
|
|
4648
4696
|
];
|
|
4649
|
-
|
|
4650
|
-
})();
|
|
4651
|
-
}
|
|
4652
|
-
}).then(function(page) {
|
|
4653
|
-
resolve({
|
|
4654
|
-
page: page,
|
|
4655
|
-
resultsCount: currentResultsCount
|
|
4697
|
+
}
|
|
4656
4698
|
});
|
|
4657
|
-
})
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4699
|
+
})();
|
|
4700
|
+
},
|
|
4701
|
+
next: function next() {
|
|
4702
|
+
return _async_to_generator(function() {
|
|
4703
|
+
return _ts_generator(this, function(_state) {
|
|
4704
|
+
return [
|
|
4705
|
+
2,
|
|
4706
|
+
accumulator.itemIteration.nextPage()
|
|
4707
|
+
];
|
|
4708
|
+
});
|
|
4709
|
+
})();
|
|
4710
|
+
}
|
|
4711
|
+
}).then(function(page) {
|
|
4712
|
+
resolve({
|
|
4713
|
+
page: page,
|
|
4714
|
+
resultsCount: currentResultsCount
|
|
4664
4715
|
});
|
|
4665
|
-
})()
|
|
4716
|
+
}).catch(function(error) {
|
|
4717
|
+
reject(error);
|
|
4718
|
+
throw error;
|
|
4719
|
+
});
|
|
4666
4720
|
},
|
|
4667
4721
|
error: function error(error) {
|
|
4668
4722
|
reject(error);
|
|
@@ -5161,11 +5215,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5161
5215
|
hasNextPage: util.invertMaybeBoolean(end)
|
|
5162
5216
|
});
|
|
5163
5217
|
}
|
|
5164
|
-
|
|
5218
|
+
return {
|
|
5165
5219
|
n: request.n,
|
|
5166
5220
|
state: state
|
|
5167
5221
|
};
|
|
5168
|
-
return result;
|
|
5169
5222
|
}));
|
|
5170
5223
|
}), rxjs.scan(function(acc, x) {
|
|
5171
5224
|
var n = x.n, curr = x.state;
|
|
@@ -5178,19 +5231,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5178
5231
|
lastSuccessful: acc.lastSuccessful
|
|
5179
5232
|
};
|
|
5180
5233
|
// If it was a replay of the previous result, change nothing.
|
|
5181
|
-
if (acc.current !== curr) {
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
if (!next.firstSuccessful) {
|
|
5191
|
-
next.firstSuccessful = curr;
|
|
5192
|
-
}
|
|
5193
|
-
}
|
|
5234
|
+
if (acc.current !== curr && isLoadingStateFinishedLoading(curr)) {
|
|
5235
|
+
var // only set first finished once
|
|
5236
|
+
_next, _firstFinished;
|
|
5237
|
+
(_firstFinished = (_next = next).firstFinished) !== null && _firstFinished !== void 0 ? _firstFinished : _next.firstFinished = curr;
|
|
5238
|
+
next.latestFinished = curr;
|
|
5239
|
+
if (!isLoadingStateWithError(curr)) {
|
|
5240
|
+
var _next1, _firstSuccessful;
|
|
5241
|
+
next.lastSuccessful = curr;
|
|
5242
|
+
(_firstSuccessful = (_next1 = next).firstSuccessful) !== null && _firstSuccessful !== void 0 ? _firstSuccessful : _next1.firstSuccessful = curr;
|
|
5194
5243
|
}
|
|
5195
5244
|
}
|
|
5196
5245
|
return next;
|
|
@@ -5499,6 +5548,10 @@ function _type_of(obj) {
|
|
|
5499
5548
|
* Useful for deferring an action until all locks are released, with a safety timeout to avoid waiting indefinitely.
|
|
5500
5549
|
*
|
|
5501
5550
|
* @param config - configuration specifying the lock set, callback, timeout, and optional delay
|
|
5551
|
+
* @param config.lockSet - the lock set to monitor for the next unlock event
|
|
5552
|
+
* @param config.fn - optional callback to invoke when the lock set unlocks or the timeout is reached
|
|
5553
|
+
* @param config.timeout - maximum time in milliseconds to wait before timing out
|
|
5554
|
+
* @param config.delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
5502
5555
|
* @returns subscription that can be unsubscribed to cancel the wait
|
|
5503
5556
|
*
|
|
5504
5557
|
* @example
|
|
@@ -5926,14 +5979,14 @@ function _define_property(obj, key, value) {
|
|
|
5926
5979
|
*
|
|
5927
5980
|
* If the loading state returns an error, the error is forwarded.
|
|
5928
5981
|
*
|
|
5929
|
-
* @param loadingStateObs
|
|
5982
|
+
* @param loadingStateObs - observable of the loading state to track as the work result
|
|
5930
5983
|
*/ key: "startWorkingWithLoadingStateObservable",
|
|
5931
5984
|
value: function startWorkingWithLoadingStateObservable(loadingStateObs) {
|
|
5932
5985
|
var _this = this;
|
|
5933
5986
|
var obs = preventComplete(loadingStateObs).pipe(filterMaybe(), rxjs.shareReplay(1));
|
|
5934
5987
|
this._sub.subscription = obs.pipe(rxjs.delay(0), rxjs.first()).subscribe(function() {
|
|
5935
5988
|
_this.startWorkingWithObservable(obs.pipe(rxjs.filter(function(x) {
|
|
5936
|
-
return
|
|
5989
|
+
return !isLoadingStateLoading(x);
|
|
5937
5990
|
}), rxjs.map(function(x) {
|
|
5938
5991
|
if (x.error) {
|
|
5939
5992
|
throw x.error;
|
|
@@ -5952,11 +6005,12 @@ function _define_property(obj, key, value) {
|
|
|
5952
6005
|
*
|
|
5953
6006
|
* It is used in conjunction with startWorking() and ideal for cases where multiple observables or promises are used.
|
|
5954
6007
|
*
|
|
5955
|
-
* @param loadingStateObs
|
|
6008
|
+
* @param loadingStateObs - promise or observable of the loading state to track for errors
|
|
6009
|
+
* @returns a promise that resolves with the value from the loading state or rejects on error
|
|
5956
6010
|
*/ key: "performTaskWithLoadingState",
|
|
5957
6011
|
value: function performTaskWithLoadingState(loadingStateObs) {
|
|
5958
6012
|
var _this = this;
|
|
5959
|
-
return promiseFromLoadingState(rxjs.from(loadingStateObs).pipe(filterMaybe(), rxjs.tap(function(
|
|
6013
|
+
return promiseFromLoadingState(rxjs.from(loadingStateObs).pipe(filterMaybe(), rxjs.tap(function(_x) {
|
|
5960
6014
|
_this._setWorking(true); // mark as working if not already marked.
|
|
5961
6015
|
}))).catch(function(e) {
|
|
5962
6016
|
// catch and throw any errors.
|
|
@@ -5971,7 +6025,7 @@ function _define_property(obj, key, value) {
|
|
|
5971
6025
|
*
|
|
5972
6026
|
* If an error is thrown, the error is forwarded to the reject function.
|
|
5973
6027
|
*
|
|
5974
|
-
* @param fn
|
|
6028
|
+
* @param fn - synchronous function that returns the result value or throws an error
|
|
5975
6029
|
*/ key: "performTaskWithReturnValue",
|
|
5976
6030
|
value: function performTaskWithReturnValue(fn) {
|
|
5977
6031
|
try {
|
|
@@ -5986,6 +6040,8 @@ function _define_property(obj, key, value) {
|
|
|
5986
6040
|
{
|
|
5987
6041
|
/**
|
|
5988
6042
|
* Begins working using a promise.
|
|
6043
|
+
*
|
|
6044
|
+
* @param promise - the promise that represents the asynchronous work
|
|
5989
6045
|
*/ key: "startWorkingWithPromise",
|
|
5990
6046
|
value: function startWorkingWithPromise(promise) {
|
|
5991
6047
|
this.startWorkingWithObservable(rxjs.from(promise));
|
|
@@ -5994,6 +6050,8 @@ function _define_property(obj, key, value) {
|
|
|
5994
6050
|
{
|
|
5995
6051
|
/**
|
|
5996
6052
|
* Begins working using an observable.
|
|
6053
|
+
*
|
|
6054
|
+
* @param workObs - the observable that represents the asynchronous work and emits the result
|
|
5997
6055
|
*/ key: "startWorkingWithObservable",
|
|
5998
6056
|
value: function startWorkingWithObservable(workObs) {
|
|
5999
6057
|
var _this = this;
|
|
@@ -6020,6 +6078,8 @@ function _define_property(obj, key, value) {
|
|
|
6020
6078
|
{
|
|
6021
6079
|
/**
|
|
6022
6080
|
* Sets success on the work.
|
|
6081
|
+
*
|
|
6082
|
+
* @param result - the successful result value to pass to the delegate
|
|
6023
6083
|
*/ key: "success",
|
|
6024
6084
|
value: function success(result) {
|
|
6025
6085
|
this._setComplete(successResult(result));
|
|
@@ -6029,6 +6089,8 @@ function _define_property(obj, key, value) {
|
|
|
6029
6089
|
{
|
|
6030
6090
|
/**
|
|
6031
6091
|
* Sets rejected on the work.
|
|
6092
|
+
*
|
|
6093
|
+
* @param error - the error to pass to the delegate as the rejection reason
|
|
6032
6094
|
*/ key: "reject",
|
|
6033
6095
|
value: function reject(error) {
|
|
6034
6096
|
this._setComplete(errorResult(error));
|
|
@@ -6090,6 +6152,8 @@ function _define_property(obj, key, value) {
|
|
|
6090
6152
|
* ```
|
|
6091
6153
|
*
|
|
6092
6154
|
* @param config - work function and delegate configuration
|
|
6155
|
+
* @param config.work - the work function to execute for each input value
|
|
6156
|
+
* @param config.delegate - delegate that receives lifecycle callbacks (start, success, reject)
|
|
6093
6157
|
* @returns a factory function that creates WorkInstance for each input
|
|
6094
6158
|
*/ function workFactory(param) {
|
|
6095
6159
|
var work = param.work, delegate = param.delegate;
|
|
@@ -6103,13 +6167,11 @@ function _define_property(obj, key, value) {
|
|
|
6103
6167
|
handler.reject(e);
|
|
6104
6168
|
return;
|
|
6105
6169
|
}
|
|
6106
|
-
if (!handler.isComplete) {
|
|
6107
|
-
if (
|
|
6108
|
-
|
|
6109
|
-
throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
|
|
6110
|
-
}
|
|
6111
|
-
handler.startWorkingWithObservable(fnResult);
|
|
6170
|
+
if (!handler.isComplete && fnResult && rxjs.isObservable(fnResult)) {
|
|
6171
|
+
if (handler.hasStarted) {
|
|
6172
|
+
throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
|
|
6112
6173
|
}
|
|
6174
|
+
handler.startWorkingWithObservable(fnResult);
|
|
6113
6175
|
}
|
|
6114
6176
|
return handler;
|
|
6115
6177
|
};
|