@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.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObservable, of, switchMap, combineLatest, map, delay, startWith, filter, skipWhile, EMPTY, distinctUntilChanged, mergeMap, BehaviorSubject, shareReplay, skip, defaultIfEmpty, first, finalize, merge, firstValueFrom, exhaustMap, scan, identity, throttleTime, takeWhile, timeout, tap, throwError, timer, delayWhen, asyncScheduler, from, catchError, Subject } from 'rxjs';
|
|
2
|
-
import { getValueFromGetter, isMaybeSo, filterMaybeArrayValues, areEqualPOJOValues, convertToArray, asGetter, performTaskLoop, isMaybeNot, forEachWithArray, pushArrayItemsIntoArray,
|
|
2
|
+
import { getValueFromGetter, isMaybeSo, filterMaybeArrayValues, areEqualPOJOValues, convertToArray, asGetter, performTaskLoop, isMaybeNot, forEachWithArray, pushArrayItemsIntoArray, asArray, pushItemOrArrayItemsIntoArray, filterAndMapFunction, expirationDetails, objectKeysEqualityComparatorFunction, objectKeyEqualityComparatorFunction, asPromise, randomNumberFactory, mapsHaveSameKeys, mapKeysIntersectionObjectToArray, incrementingNumberFactory, filterUniqueFunction, build, cachedGetter, allKeyValueTuples, keyValueMapFactory, multiKeyValueMapFactory, timePeriodCounter, hasSameValues, compareEqualityWithValueFromItemsFunction, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, searchStringFilterFunction, reduceBooleansWithAnd, toReadableError, reduceBooleansWithOr, valuesAreBothNullishOrEquivalent, mergeObjects, objectHasKey, safeCompareEquality, hasNonNullValue, limitArray, mapFunctionOutputPair, lastValue, flattenArray, hasValueOrNotEmpty, filteredPage, invertMaybeBoolean, FIRST_PAGE, getNextPageNumber, reduceBooleansWithOrFn, MS_IN_SECOND } from '@dereekb/util';
|
|
3
3
|
|
|
4
4
|
function asObservable(valueOrObs) {
|
|
5
5
|
if (isObservable(valueOrObs)) {
|
|
@@ -43,6 +43,8 @@ function asObservableFromGetter(input, args) {
|
|
|
43
43
|
/**
|
|
44
44
|
* RxJS operator that flattens an emitted Maybe<{@link ObservableOrValueGetter}> into its resolved value,
|
|
45
45
|
* emitting `undefined` when the input is nullish.
|
|
46
|
+
*
|
|
47
|
+
* @returns an operator that unwraps Maybe<ObservableOrValueGetter> emissions, emitting undefined for nullish inputs
|
|
46
48
|
*/ function maybeValueFromObservableOrValueGetter() {
|
|
47
49
|
return switchMap(function(x) {
|
|
48
50
|
return x != null ? asObservableFromGetter(x) : of(undefined);
|
|
@@ -137,6 +139,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
137
139
|
*
|
|
138
140
|
* @param isCheckFunction - optional check function
|
|
139
141
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
142
|
+
* @returns a function that evaluates each value against the check function and returns it or undefined
|
|
140
143
|
*/ function makeReturnIfIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
141
144
|
return function(value) {
|
|
142
145
|
return returnIfIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
@@ -148,6 +151,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
148
151
|
* @param isCheckFunction - optional check function
|
|
149
152
|
* @param value - the value to check
|
|
150
153
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
154
|
+
* @returns an observable that emits the value if the check passes, or undefined otherwise
|
|
151
155
|
*/ function returnIfIs(isCheckFunction, value, defaultValueOnMaybe) {
|
|
152
156
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe).pipe(map(function(x) {
|
|
153
157
|
return x ? value : undefined;
|
|
@@ -158,6 +162,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
158
162
|
*
|
|
159
163
|
* @param isCheckFunction - optional check function
|
|
160
164
|
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
165
|
+
* @returns a function that evaluates each value against the check function and returns an observable boolean
|
|
161
166
|
*/ function makeCheckIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
162
167
|
return function(value) {
|
|
163
168
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
@@ -171,6 +176,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
171
176
|
* @param isCheckFunction - optional check function
|
|
172
177
|
* @param value - the value to check
|
|
173
178
|
* @param defaultValueOnMaybe - default result for null/undefined values (defaults to false)
|
|
179
|
+
* @returns an observable boolean indicating whether the value passes the check
|
|
174
180
|
*/ function checkIs(isCheckFunction, value) {
|
|
175
181
|
var defaultValueOnMaybe = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
176
182
|
var is = isCheckFunction ? value != null ? isCheckFunction(value) : of(defaultValueOnMaybe) : of(true);
|
|
@@ -179,6 +185,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
179
185
|
// MARK: Filter
|
|
180
186
|
/**
|
|
181
187
|
* RxJS operator that filters out null and undefined values, only passing through defined values.
|
|
188
|
+
*
|
|
189
|
+
* @returns operator that filters out null and undefined emissions
|
|
182
190
|
*/ function filterMaybe() {
|
|
183
191
|
return filter(isMaybeSo);
|
|
184
192
|
}
|
|
@@ -187,11 +195,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
187
195
|
*/ var filterMaybeStrict = filterMaybe;
|
|
188
196
|
/**
|
|
189
197
|
* RxJS operator that filters out null/undefined elements from an emitted array, keeping only defined values.
|
|
198
|
+
*
|
|
199
|
+
* @returns operator that maps each emitted array to a version with null/undefined elements removed
|
|
190
200
|
*/ function filterMaybeArray() {
|
|
191
201
|
return map(filterMaybeArrayValues);
|
|
192
202
|
}
|
|
193
203
|
/**
|
|
194
204
|
* RxJS operator that skips all leading null/undefined emissions, then passes all subsequent values through.
|
|
205
|
+
*
|
|
206
|
+
* @returns operator that skips all null/undefined emissions at the start of the stream
|
|
195
207
|
*/ function skipAllInitialMaybe() {
|
|
196
208
|
return skipWhile(function(x) {
|
|
197
209
|
return x == null;
|
|
@@ -199,6 +211,8 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
199
211
|
}
|
|
200
212
|
/**
|
|
201
213
|
* RxJS operator that skips only the first emission if it is null/undefined, then passes all subsequent values.
|
|
214
|
+
*
|
|
215
|
+
* @returns operator that skips the first null/undefined emission if it occurs at the start of the stream
|
|
202
216
|
*/ function skipInitialMaybe() {
|
|
203
217
|
return skipMaybes(1);
|
|
204
218
|
}
|
|
@@ -206,6 +220,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
206
220
|
* RxJS operator that skips up to `maxToSkip` null/undefined emissions, then passes all subsequent values.
|
|
207
221
|
*
|
|
208
222
|
* @param maxToSkip - maximum number of null/undefined emissions to skip
|
|
223
|
+
* @returns operator that skips the first N null/undefined emissions from the stream
|
|
209
224
|
*/ function skipMaybes(maxToSkip) {
|
|
210
225
|
return skipWhile(function(x, i) {
|
|
211
226
|
return x == null && i < maxToSkip;
|
|
@@ -227,7 +242,7 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
227
242
|
});
|
|
228
243
|
}
|
|
229
244
|
function switchMapToDefault(defaultObs, useDefault) {
|
|
230
|
-
var useDefaultFn = useDefault ? useDefault : function(x) {
|
|
245
|
+
var useDefaultFn = useDefault !== null && useDefault !== void 0 ? useDefault : function(x) {
|
|
231
246
|
return of(x == null);
|
|
232
247
|
};
|
|
233
248
|
return switchMap(function(x) {
|
|
@@ -243,6 +258,9 @@ function switchMapToDefault(defaultObs, useDefault) {
|
|
|
243
258
|
/**
|
|
244
259
|
* RxJS operator that resolves an observable/getter config input into a value, applying defaults
|
|
245
260
|
* for `null`/`undefined`/`true` inputs and emitting `null` for `false`.
|
|
261
|
+
*
|
|
262
|
+
* @param config - configuration providing an optional default getter for null/undefined/true inputs
|
|
263
|
+
* @returns operator that resolves each emitted getter into a value, using the default for nullish or true inputs
|
|
246
264
|
*/ function switchMapObject(config) {
|
|
247
265
|
var defaultGetter = config.defaultGetter;
|
|
248
266
|
return switchMap(function(inputConfig) {
|
|
@@ -277,6 +295,8 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
277
295
|
* RxJS operator that filters out null/undefined observables and then switches to the remaining ones.
|
|
278
296
|
*
|
|
279
297
|
* Combines {@link filterMaybe} and `switchMap` to only subscribe to non-nullish observables.
|
|
298
|
+
*
|
|
299
|
+
* @returns operator that filters nullish observables and subscribes to the non-nullish ones
|
|
280
300
|
*/ function switchMapFilterMaybe() {
|
|
281
301
|
return function(source) {
|
|
282
302
|
var subscriber = source.pipe(filterMaybe(), switchMap(function(x) {
|
|
@@ -287,10 +307,12 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
287
307
|
}
|
|
288
308
|
/**
|
|
289
309
|
* RxJS operator that switches to the emitted observable if defined, or emits `undefined` when the observable is nullish.
|
|
310
|
+
*
|
|
311
|
+
* @returns operator that switches to the emitted observable or emits undefined for null/undefined inputs
|
|
290
312
|
*/ function switchMapMaybe() {
|
|
291
313
|
return function(source) {
|
|
292
314
|
var subscriber = source.pipe(switchMap(function(x) {
|
|
293
|
-
return x
|
|
315
|
+
return x !== null && x !== void 0 ? x : of(undefined);
|
|
294
316
|
}));
|
|
295
317
|
return subscriber;
|
|
296
318
|
};
|
|
@@ -315,11 +337,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
315
337
|
});
|
|
316
338
|
}
|
|
317
339
|
/**
|
|
318
|
-
* Combines
|
|
340
|
+
* Combines the source observable with another observable via `combineLatest`, then maps the pair to a result.
|
|
319
341
|
*
|
|
320
|
-
* @param combineObs
|
|
321
|
-
* @param mapFn
|
|
322
|
-
* @returns
|
|
342
|
+
* @param combineObs - the secondary observable to combine with the source
|
|
343
|
+
* @param mapFn - function that maps the source value and combined value to the output
|
|
344
|
+
* @returns operator that combines the source with `combineObs` and maps each pair using `mapFn`
|
|
323
345
|
*/ function combineLatestMapFrom(combineObs, mapFn) {
|
|
324
346
|
return function(obs) {
|
|
325
347
|
return combineLatest([
|
|
@@ -335,6 +357,11 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
335
357
|
* Creates an observable that emits a starting value, then a second value after a delay.
|
|
336
358
|
*
|
|
337
359
|
* If the delay is not provided, or is falsy, then the second value is never emitted.
|
|
360
|
+
*
|
|
361
|
+
* @param startWith - the value to emit immediately
|
|
362
|
+
* @param endWith - the value to emit after the delay
|
|
363
|
+
* @param delayTime - optional delay in milliseconds before emitting the second value
|
|
364
|
+
* @returns an observable that emits `startWith` immediately and `endWith` after the delay (if provided)
|
|
338
365
|
*/ function emitDelayObs(startWith, endWith, delayTime) {
|
|
339
366
|
var obs = of(startWith);
|
|
340
367
|
if (delayTime) {
|
|
@@ -344,6 +371,10 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
344
371
|
}
|
|
345
372
|
/**
|
|
346
373
|
* Emits a value after a given delay after every new emission.
|
|
374
|
+
*
|
|
375
|
+
* @param value - the value to emit after the delay
|
|
376
|
+
* @param delayTime - duration in milliseconds before emitting the value
|
|
377
|
+
* @returns operator that appends the given value after each source emission with the specified delay
|
|
347
378
|
*/ function emitAfterDelay(value, delayTime) {
|
|
348
379
|
return function(obs) {
|
|
349
380
|
return obs.pipe(switchMap(function(x) {
|
|
@@ -386,7 +417,7 @@ function _array_like_to_array$a(arr, len) {
|
|
|
386
417
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
387
418
|
return arr2;
|
|
388
419
|
}
|
|
389
|
-
function _array_without_holes$
|
|
420
|
+
function _array_without_holes$6(arr) {
|
|
390
421
|
if (Array.isArray(arr)) return _array_like_to_array$a(arr);
|
|
391
422
|
}
|
|
392
423
|
function _class_call_check$8(instance, Constructor) {
|
|
@@ -420,14 +451,14 @@ function _define_property$c(obj, key, value) {
|
|
|
420
451
|
}
|
|
421
452
|
return obj;
|
|
422
453
|
}
|
|
423
|
-
function _iterable_to_array$
|
|
454
|
+
function _iterable_to_array$6(iter) {
|
|
424
455
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
425
456
|
}
|
|
426
|
-
function _non_iterable_spread$
|
|
457
|
+
function _non_iterable_spread$6() {
|
|
427
458
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
428
459
|
}
|
|
429
|
-
function _to_consumable_array$
|
|
430
|
-
return _array_without_holes$
|
|
460
|
+
function _to_consumable_array$6(arr) {
|
|
461
|
+
return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$6();
|
|
431
462
|
}
|
|
432
463
|
function _unsupported_iterable_to_array$a(o, minLen) {
|
|
433
464
|
if (!o) return;
|
|
@@ -467,6 +498,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
467
498
|
key: "hasSubscription",
|
|
468
499
|
get: /**
|
|
469
500
|
* Whether a subscription is currently being managed.
|
|
501
|
+
*
|
|
502
|
+
* @returns true if a subscription is currently active
|
|
470
503
|
*/ function get() {
|
|
471
504
|
return Boolean(this._subscription);
|
|
472
505
|
}
|
|
@@ -546,6 +579,8 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
546
579
|
key: "hasSubscription",
|
|
547
580
|
get: /**
|
|
548
581
|
* Whether any subscriptions are currently being managed.
|
|
582
|
+
*
|
|
583
|
+
* @returns true if one or more subscriptions are currently active
|
|
549
584
|
*/ function get() {
|
|
550
585
|
var _this__subscriptions;
|
|
551
586
|
return Boolean((_this__subscriptions = this._subscriptions) === null || _this__subscriptions === void 0 ? void 0 : _this__subscriptions.length);
|
|
@@ -578,7 +613,7 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
578
613
|
*/ key: "addSubs",
|
|
579
614
|
value: function addSubs(subs) {
|
|
580
615
|
var _this__subscriptions;
|
|
581
|
-
var nextSubscriptions = _to_consumable_array$
|
|
616
|
+
var nextSubscriptions = _to_consumable_array$6((_this__subscriptions = this._subscriptions) !== null && _this__subscriptions !== void 0 ? _this__subscriptions : []);
|
|
582
617
|
convertToArray(subs).forEach(function(sub) {
|
|
583
618
|
if (!nextSubscriptions.includes(sub)) {
|
|
584
619
|
nextSubscriptions.push(sub);
|
|
@@ -811,24 +846,23 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
811
846
|
key: "initFilterTakesPriority",
|
|
812
847
|
value: function initFilterTakesPriority() {
|
|
813
848
|
var _this = this;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
849
|
+
var _this__initialFilterSub, _subscription;
|
|
850
|
+
(_subscription = (_this__initialFilterSub = this._initialFilterSub).subscription) !== null && _subscription !== void 0 ? _subscription : _this__initialFilterSub.subscription = this._initialFilterTakesPriority.pipe(switchMap(function(clearFilterOnInitialFilterPush) {
|
|
851
|
+
if (clearFilterOnInitialFilterPush) {
|
|
852
|
+
return _this._initialFilter.pipe(switchMap(function(x) {
|
|
853
|
+
return x !== null && x !== void 0 ? x : EMPTY;
|
|
854
|
+
}), filterMaybe(), map(function() {
|
|
855
|
+
return true;
|
|
856
|
+
}), skip(1) // skip the first emission
|
|
857
|
+
);
|
|
858
|
+
} else {
|
|
859
|
+
return EMPTY;
|
|
860
|
+
}
|
|
861
|
+
}), defaultIfEmpty(false)).subscribe(function(clear) {
|
|
862
|
+
if (clear) {
|
|
863
|
+
_this.resetFilter();
|
|
864
|
+
}
|
|
865
|
+
});
|
|
832
866
|
}
|
|
833
867
|
},
|
|
834
868
|
{
|
|
@@ -853,7 +887,7 @@ function _array_like_to_array$8(arr, len) {
|
|
|
853
887
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
854
888
|
return arr2;
|
|
855
889
|
}
|
|
856
|
-
function _array_without_holes$
|
|
890
|
+
function _array_without_holes$5(arr) {
|
|
857
891
|
if (Array.isArray(arr)) return _array_like_to_array$8(arr);
|
|
858
892
|
}
|
|
859
893
|
function _class_call_check$6(instance, Constructor) {
|
|
@@ -887,14 +921,14 @@ function _define_property$a(obj, key, value) {
|
|
|
887
921
|
}
|
|
888
922
|
return obj;
|
|
889
923
|
}
|
|
890
|
-
function _iterable_to_array$
|
|
924
|
+
function _iterable_to_array$5(iter) {
|
|
891
925
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
892
926
|
}
|
|
893
|
-
function _non_iterable_spread$
|
|
927
|
+
function _non_iterable_spread$5() {
|
|
894
928
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
895
929
|
}
|
|
896
|
-
function _to_consumable_array$
|
|
897
|
-
return _array_without_holes$
|
|
930
|
+
function _to_consumable_array$5(arr) {
|
|
931
|
+
return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$5();
|
|
898
932
|
}
|
|
899
933
|
function _unsupported_iterable_to_array$8(o, minLen) {
|
|
900
934
|
if (!o) return;
|
|
@@ -1053,6 +1087,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
1053
1087
|
{
|
|
1054
1088
|
/**
|
|
1055
1089
|
* Sets the default filter observable for this key.
|
|
1090
|
+
*
|
|
1091
|
+
* @param filterObs - the observable to use as the default filter for this key
|
|
1056
1092
|
*/ key: "initWithFilter",
|
|
1057
1093
|
value: function initWithFilter(filterObs) {
|
|
1058
1094
|
this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
|
|
@@ -1061,6 +1097,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
1061
1097
|
{
|
|
1062
1098
|
/**
|
|
1063
1099
|
* Connects a filter source, adding its filter observable to this key's merged filters.
|
|
1100
|
+
*
|
|
1101
|
+
* @param filterSource - the filter source whose filter$ will be added to this key's merged stream
|
|
1064
1102
|
*/ key: "connectWithSource",
|
|
1065
1103
|
value: function connectWithSource(filterSource) {
|
|
1066
1104
|
this.dbxFilterMap.addFilterObs(this.key, filterSource.filter$);
|
|
@@ -1078,7 +1116,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
|
|
|
1078
1116
|
_define_property$a(this, "_source", new FilterSourceInstance());
|
|
1079
1117
|
_define_property$a(this, "_obs", new BehaviorSubject([]));
|
|
1080
1118
|
_define_property$a(this, "_obs$", this._obs.pipe(switchMap(function(x) {
|
|
1081
|
-
return merge.apply(void 0, _to_consumable_array$
|
|
1119
|
+
return merge.apply(void 0, _to_consumable_array$5(x.map(function(y) {
|
|
1082
1120
|
return y.obs;
|
|
1083
1121
|
})));
|
|
1084
1122
|
}), distinctUntilChanged()));
|
|
@@ -1119,7 +1157,7 @@ var FilterMapItem = /*#__PURE__*/ function() {
|
|
|
1119
1157
|
var deleteOnComplete = obs.pipe(finalize(function() {
|
|
1120
1158
|
_this._deleteFilterObs(i);
|
|
1121
1159
|
})).subscribe();
|
|
1122
|
-
var nextObs = _to_consumable_array$
|
|
1160
|
+
var nextObs = _to_consumable_array$5(currentObs).concat([
|
|
1123
1161
|
{
|
|
1124
1162
|
i: i,
|
|
1125
1163
|
obs: obs,
|
|
@@ -1496,18 +1534,10 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1496
1534
|
next: function next() {
|
|
1497
1535
|
return _async_to_generator$1(function() {
|
|
1498
1536
|
return _ts_generator$1(this, function(_state) {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
iteration.nextPage()
|
|
1504
|
-
];
|
|
1505
|
-
case 1:
|
|
1506
|
-
return [
|
|
1507
|
-
2,
|
|
1508
|
-
_state.sent()
|
|
1509
|
-
];
|
|
1510
|
-
}
|
|
1537
|
+
return [
|
|
1538
|
+
2,
|
|
1539
|
+
iteration.nextPage()
|
|
1540
|
+
];
|
|
1511
1541
|
});
|
|
1512
1542
|
})();
|
|
1513
1543
|
}
|
|
@@ -1526,17 +1556,17 @@ function _array_like_to_array$7(arr, len) {
|
|
|
1526
1556
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1527
1557
|
return arr2;
|
|
1528
1558
|
}
|
|
1529
|
-
function _array_without_holes$
|
|
1559
|
+
function _array_without_holes$4(arr) {
|
|
1530
1560
|
if (Array.isArray(arr)) return _array_like_to_array$7(arr);
|
|
1531
1561
|
}
|
|
1532
|
-
function _iterable_to_array$
|
|
1562
|
+
function _iterable_to_array$4(iter) {
|
|
1533
1563
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1534
1564
|
}
|
|
1535
|
-
function _non_iterable_spread$
|
|
1565
|
+
function _non_iterable_spread$4() {
|
|
1536
1566
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1537
1567
|
}
|
|
1538
|
-
function _to_consumable_array$
|
|
1539
|
-
return _array_without_holes$
|
|
1568
|
+
function _to_consumable_array$4(arr) {
|
|
1569
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$4();
|
|
1540
1570
|
}
|
|
1541
1571
|
function _unsupported_iterable_to_array$7(o, minLen) {
|
|
1542
1572
|
if (!o) return;
|
|
@@ -1562,7 +1592,7 @@ function scanIntoArray() {
|
|
|
1562
1592
|
return scan(function(acc, next) {
|
|
1563
1593
|
if (next != null) {
|
|
1564
1594
|
if (immutable) {
|
|
1565
|
-
acc = acc.concat(next);
|
|
1595
|
+
acc = _to_consumable_array$4(acc).concat(_to_consumable_array$4(asArray(next)));
|
|
1566
1596
|
} else {
|
|
1567
1597
|
acc = pushItemOrArrayItemsIntoArray(acc, next);
|
|
1568
1598
|
}
|
|
@@ -1592,7 +1622,7 @@ function scanIntoArray() {
|
|
|
1592
1622
|
}
|
|
1593
1623
|
return acc;
|
|
1594
1624
|
}, seed !== null && seed !== void 0 ? seed : []), distinctUntilArrayLengthChanges(), map(function(x) {
|
|
1595
|
-
return _to_consumable_array$
|
|
1625
|
+
return _to_consumable_array$4(x);
|
|
1596
1626
|
}), shareReplay(1));
|
|
1597
1627
|
});
|
|
1598
1628
|
}
|
|
@@ -1682,7 +1712,7 @@ function scanIntoArray() {
|
|
|
1682
1712
|
if (!acc.fromMatch || requireConsecutive) {
|
|
1683
1713
|
fromMatch = isMatch(from, next);
|
|
1684
1714
|
value = next;
|
|
1685
|
-
} else
|
|
1715
|
+
} else {
|
|
1686
1716
|
value = acc.value;
|
|
1687
1717
|
}
|
|
1688
1718
|
}
|
|
@@ -1716,6 +1746,8 @@ function scanIntoArray() {
|
|
|
1716
1746
|
}
|
|
1717
1747
|
/**
|
|
1718
1748
|
* RxJS operator that negates each emitted boolean value.
|
|
1749
|
+
*
|
|
1750
|
+
* @returns operator that maps each boolean emission to its negated value
|
|
1719
1751
|
*/ function isNot() {
|
|
1720
1752
|
return map(function(x) {
|
|
1721
1753
|
return !x;
|
|
@@ -1723,6 +1755,8 @@ function scanIntoArray() {
|
|
|
1723
1755
|
}
|
|
1724
1756
|
/**
|
|
1725
1757
|
* RxJS operator that only emits when a boolean stream transitions from `true` to `false`.
|
|
1758
|
+
*
|
|
1759
|
+
* @returns operator that filters to only true-to-false transition emissions
|
|
1726
1760
|
*/ function onTrueToFalse() {
|
|
1727
1761
|
return onMatchDelta({
|
|
1728
1762
|
from: true,
|
|
@@ -1732,6 +1766,8 @@ function scanIntoArray() {
|
|
|
1732
1766
|
}
|
|
1733
1767
|
/**
|
|
1734
1768
|
* RxJS operator that only emits when a boolean stream transitions from `false` to `true`.
|
|
1769
|
+
*
|
|
1770
|
+
* @returns operator that filters to only false-to-true transition emissions
|
|
1735
1771
|
*/ function onFalseToTrue() {
|
|
1736
1772
|
return onMatchDelta({
|
|
1737
1773
|
from: false,
|
|
@@ -1804,7 +1840,7 @@ function scanIntoArray() {
|
|
|
1804
1840
|
* time relative to the current moment.
|
|
1805
1841
|
*
|
|
1806
1842
|
* @param expiresIn - duration in milliseconds until expiration
|
|
1807
|
-
* @returns an
|
|
1843
|
+
* @returns an `OperatorFunction` that maps each emission to an {@link Expires} object
|
|
1808
1844
|
*/ function toExpiration(expiresIn) {
|
|
1809
1845
|
return map(function() {
|
|
1810
1846
|
var now = new Date();
|
|
@@ -1819,6 +1855,8 @@ function scanIntoArray() {
|
|
|
1819
1855
|
}
|
|
1820
1856
|
/**
|
|
1821
1857
|
* RxJS operator that filters out emissions whose {@link Expires} value has already expired.
|
|
1858
|
+
*
|
|
1859
|
+
* @returns operator that only passes through non-expired emissions
|
|
1822
1860
|
*/ function skipExpired() {
|
|
1823
1861
|
return filter(function(expires) {
|
|
1824
1862
|
return !expirationDetails({
|
|
@@ -1830,6 +1868,7 @@ function scanIntoArray() {
|
|
|
1830
1868
|
* RxJS operator that skips emissions until the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1831
1869
|
*
|
|
1832
1870
|
* @param expiresIn - duration in milliseconds
|
|
1871
|
+
* @returns operator that skips emissions until the time window has elapsed
|
|
1833
1872
|
*/ function skipUntilExpiration(expiresIn) {
|
|
1834
1873
|
return filter(function(x) {
|
|
1835
1874
|
return expirationDetails({
|
|
@@ -1842,6 +1881,7 @@ function scanIntoArray() {
|
|
|
1842
1881
|
* RxJS operator that skips emissions after the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1843
1882
|
*
|
|
1844
1883
|
* @param expiresIn - duration in milliseconds
|
|
1884
|
+
* @returns operator that passes through emissions only within the time window
|
|
1845
1885
|
*/ function skipAfterExpiration(expiresIn) {
|
|
1846
1886
|
return filter(function(x) {
|
|
1847
1887
|
return !expirationDetails({
|
|
@@ -1855,6 +1895,7 @@ function scanIntoArray() {
|
|
|
1855
1895
|
*
|
|
1856
1896
|
* @param watch - observable whose emissions reset the time window
|
|
1857
1897
|
* @param takeFor - duration in milliseconds of each time window
|
|
1898
|
+
* @returns operator that limits source emissions to the active time window after each watch emission
|
|
1858
1899
|
*/ function skipUntilTimeElapsedAfterLastEmission(watch, takeFor) {
|
|
1859
1900
|
return function(observable) {
|
|
1860
1901
|
return watch.pipe(switchMap(function() {
|
|
@@ -1874,6 +1915,7 @@ function scanIntoArray() {
|
|
|
1874
1915
|
*
|
|
1875
1916
|
* @param watch - observable whose emissions reset the skip window
|
|
1876
1917
|
* @param skipFor - duration in milliseconds to skip after each watch emission
|
|
1918
|
+
* @returns an operator that delays passing values through until time has elapsed since the last watch emission
|
|
1877
1919
|
*/ function takeAfterTimeElapsedSinceLastEmission(watch, skipFor) {
|
|
1878
1920
|
return function(observable) {
|
|
1879
1921
|
return watch.pipe(switchMap(function() {
|
|
@@ -2025,7 +2067,7 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
|
2025
2067
|
return result;
|
|
2026
2068
|
}), finalize(function() {
|
|
2027
2069
|
if (currentInstance) {
|
|
2028
|
-
destroy(currentInstance);
|
|
2070
|
+
void destroy(currentInstance);
|
|
2029
2071
|
}
|
|
2030
2072
|
}));
|
|
2031
2073
|
};
|
|
@@ -2101,6 +2143,8 @@ function tapLog(messageOrFunction) {
|
|
|
2101
2143
|
|
|
2102
2144
|
/**
|
|
2103
2145
|
* `distinctUntilChanged` variant that only emits when the model's `id` property changes.
|
|
2146
|
+
*
|
|
2147
|
+
* @returns operator that suppresses consecutive emissions with the same model `id`
|
|
2104
2148
|
*/ function distinctUntilModelIdChange() {
|
|
2105
2149
|
return distinctUntilObjectKeyChange(function(x) {
|
|
2106
2150
|
return x.id;
|
|
@@ -2108,6 +2152,8 @@ function tapLog(messageOrFunction) {
|
|
|
2108
2152
|
}
|
|
2109
2153
|
/**
|
|
2110
2154
|
* `distinctUntilChanged` variant that only emits when the model's `key` property changes.
|
|
2155
|
+
*
|
|
2156
|
+
* @returns operator that suppresses consecutive emissions with the same model `key`
|
|
2111
2157
|
*/ function distinctUntilModelKeyChange() {
|
|
2112
2158
|
return distinctUntilObjectKeyChange(function(x) {
|
|
2113
2159
|
return x.key;
|
|
@@ -2423,6 +2469,12 @@ function _array_like_to_array$5(arr, len) {
|
|
|
2423
2469
|
function _array_with_holes$2(arr) {
|
|
2424
2470
|
if (Array.isArray(arr)) return arr;
|
|
2425
2471
|
}
|
|
2472
|
+
function _array_without_holes$3(arr) {
|
|
2473
|
+
if (Array.isArray(arr)) return _array_like_to_array$5(arr);
|
|
2474
|
+
}
|
|
2475
|
+
function _iterable_to_array$3(iter) {
|
|
2476
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2477
|
+
}
|
|
2426
2478
|
function _iterable_to_array_limit$2(arr, i) {
|
|
2427
2479
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2428
2480
|
if (_i == null) return;
|
|
@@ -2450,9 +2502,15 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
2450
2502
|
function _non_iterable_rest$2() {
|
|
2451
2503
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2452
2504
|
}
|
|
2505
|
+
function _non_iterable_spread$3() {
|
|
2506
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2507
|
+
}
|
|
2453
2508
|
function _sliced_to_array$2(arr, i) {
|
|
2454
2509
|
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$2();
|
|
2455
2510
|
}
|
|
2511
|
+
function _to_consumable_array$3(arr) {
|
|
2512
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$3();
|
|
2513
|
+
}
|
|
2456
2514
|
function _unsupported_iterable_to_array$5(o, minLen) {
|
|
2457
2515
|
if (!o) return;
|
|
2458
2516
|
if (typeof o === "string") return _array_like_to_array$5(o, minLen);
|
|
@@ -2470,7 +2528,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2470
2528
|
*/ function combineLatestFromMapValuesObsFn(mapToObs) {
|
|
2471
2529
|
var combineArrayFn = combineLatestFromArrayObsFn(mapToObs);
|
|
2472
2530
|
return function(latestMap) {
|
|
2473
|
-
var mapValues =
|
|
2531
|
+
var mapValues = _to_consumable_array$3(latestMap).map(function(y) {
|
|
2474
2532
|
return y[1];
|
|
2475
2533
|
});
|
|
2476
2534
|
return combineArrayFn(mapValues);
|
|
@@ -2563,7 +2621,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2563
2621
|
*/ function errorOnEmissionsInPeriod(config) {
|
|
2564
2622
|
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;
|
|
2565
2623
|
var errorMessage = inputErrorMessage !== null && inputErrorMessage !== void 0 ? inputErrorMessage : 'errorOnEmissionsInPeriod(): Too many emissions in time period.';
|
|
2566
|
-
var errorFactory = inputErrorFactory ? inputErrorFactory : !switchToObs ? function() {
|
|
2624
|
+
var errorFactory = inputErrorFactory !== null && inputErrorFactory !== void 0 ? inputErrorFactory : !switchToObs ? function() {
|
|
2567
2625
|
return new Error(errorMessage);
|
|
2568
2626
|
} : undefined;
|
|
2569
2627
|
return function(source) {
|
|
@@ -2623,6 +2681,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2623
2681
|
}
|
|
2624
2682
|
/**
|
|
2625
2683
|
* `distinctUntilChanged` variant for iterables that only emits when the contained values change.
|
|
2684
|
+
*
|
|
2685
|
+
* @returns operator that suppresses consecutive iterable emissions with the same set of values
|
|
2626
2686
|
*/ function distinctUntilHasDifferentValues() {
|
|
2627
2687
|
return distinctUntilChanged(hasSameValues);
|
|
2628
2688
|
}
|
|
@@ -2876,7 +2936,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2876
2936
|
if (loading === true) {
|
|
2877
2937
|
result = false;
|
|
2878
2938
|
} else {
|
|
2879
|
-
|
|
2939
|
+
var _state_value;
|
|
2940
|
+
result = loading === false || Boolean((_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : state.error) || state.value === null;
|
|
2880
2941
|
}
|
|
2881
2942
|
}
|
|
2882
2943
|
return result;
|
|
@@ -2892,6 +2953,8 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2892
2953
|
* // { loading: false }
|
|
2893
2954
|
* loadingStateType(state); // LoadingStateType.IDLE
|
|
2894
2955
|
* ```
|
|
2956
|
+
*
|
|
2957
|
+
* @returns a loading state with `loading: false` and no value or error
|
|
2895
2958
|
*/ function idleLoadingState() {
|
|
2896
2959
|
return {
|
|
2897
2960
|
loading: false
|
|
@@ -3016,8 +3079,7 @@ function beginLoading(state) {
|
|
|
3016
3079
|
*/ function isLoadingStateWithStateType(type) {
|
|
3017
3080
|
var defaultResult = type === LoadingStateType.IDLE ? true : false;
|
|
3018
3081
|
return function(state) {
|
|
3019
|
-
|
|
3020
|
-
return result;
|
|
3082
|
+
return state ? loadingStateType(state) === type : defaultResult;
|
|
3021
3083
|
};
|
|
3022
3084
|
}
|
|
3023
3085
|
/**
|
|
@@ -3060,8 +3122,7 @@ function beginLoading(state) {
|
|
|
3060
3122
|
* @param state - the loading state to check
|
|
3061
3123
|
* @returns true if the state has a defined (non-undefined) value
|
|
3062
3124
|
*/ function isLoadingStateWithDefinedValue(state) {
|
|
3063
|
-
|
|
3064
|
-
return result;
|
|
3125
|
+
return state ? state.value !== undefined : false;
|
|
3065
3126
|
}
|
|
3066
3127
|
/**
|
|
3067
3128
|
* Type guard that checks whether a {@link LoadingState} has a non-null error, regardless of loading status.
|
|
@@ -3075,8 +3136,7 @@ function beginLoading(state) {
|
|
|
3075
3136
|
* @param state - the loading state to check
|
|
3076
3137
|
* @returns true if the state has an error
|
|
3077
3138
|
*/ function isLoadingStateWithError(state) {
|
|
3078
|
-
|
|
3079
|
-
return result;
|
|
3139
|
+
return state ? state.error != null : false;
|
|
3080
3140
|
}
|
|
3081
3141
|
/**
|
|
3082
3142
|
* Type guard that checks whether a {@link LoadingState} has finished loading and has a defined value.
|
|
@@ -3084,8 +3144,7 @@ function beginLoading(state) {
|
|
|
3084
3144
|
* @param state - the loading state to check
|
|
3085
3145
|
* @returns true if finished loading with a non-undefined value
|
|
3086
3146
|
*/ function isLoadingStateFinishedLoadingWithDefinedValue(state) {
|
|
3087
|
-
|
|
3088
|
-
return result;
|
|
3147
|
+
return state ? isLoadingStateFinishedLoading(state) && state.value !== undefined : false;
|
|
3089
3148
|
}
|
|
3090
3149
|
/**
|
|
3091
3150
|
* Type guard that checks whether a {@link LoadingState} has finished loading and has an error.
|
|
@@ -3093,8 +3152,7 @@ function beginLoading(state) {
|
|
|
3093
3152
|
* @param state - the loading state to check
|
|
3094
3153
|
* @returns true if finished loading with an error
|
|
3095
3154
|
*/ function isLoadingStateFinishedLoadingWithError(state) {
|
|
3096
|
-
|
|
3097
|
-
return result;
|
|
3155
|
+
return state ? isLoadingStateFinishedLoading(state) && state.error != null : false;
|
|
3098
3156
|
}
|
|
3099
3157
|
/**
|
|
3100
3158
|
* Compares the metadata (page, loading, error) of two {@link PageLoadingState} instances for equivalence.
|
|
@@ -3120,12 +3178,13 @@ function beginLoading(state) {
|
|
|
3120
3178
|
*/ function isPageLoadingStateMetadataEqual(a, b) {
|
|
3121
3179
|
return valuesAreBothNullishOrEquivalent(a.page, b.page) && a.loading == b.loading && valuesAreBothNullishOrEquivalent(a.error, b.error);
|
|
3122
3180
|
}
|
|
3181
|
+
// eslint-disable-next-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
|
|
3123
3182
|
function mergeLoadingStates() {
|
|
3124
3183
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
3125
3184
|
args[_key] = arguments[_key];
|
|
3126
3185
|
}
|
|
3127
3186
|
var _loadingStates_find;
|
|
3128
|
-
var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
|
|
3187
|
+
/* eslint-enable @typescript-eslint/max-params */ var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
|
|
3129
3188
|
var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
|
|
3130
3189
|
var loadingStates = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
|
|
3131
3190
|
var mergeFn = lastValueIsMergeFn ? args[validArgs.length - 1] : function() {
|
|
@@ -3141,7 +3200,7 @@ function mergeLoadingStates() {
|
|
|
3141
3200
|
if (error) {
|
|
3142
3201
|
// ignore all loading states, except for any error-prone item that is still loading
|
|
3143
3202
|
var currentLoadings = loadingStates.map(function(x) {
|
|
3144
|
-
return
|
|
3203
|
+
return x.error ? x.loading : false;
|
|
3145
3204
|
});
|
|
3146
3205
|
var nonMaybeLoadings = currentLoadings.filter(function(x) {
|
|
3147
3206
|
return x != null;
|
|
@@ -3227,10 +3286,10 @@ function mergeLoadingStates() {
|
|
|
3227
3286
|
var mapValues = config.mapValues, mapState = config.mapState;
|
|
3228
3287
|
var loading = isAnyLoadingStateInLoadingState(input);
|
|
3229
3288
|
var error = input.map(function(x) {
|
|
3230
|
-
return x
|
|
3231
|
-
}).
|
|
3289
|
+
return x.error;
|
|
3290
|
+
}).find(function(x) {
|
|
3232
3291
|
return Boolean(x);
|
|
3233
|
-
})
|
|
3292
|
+
});
|
|
3234
3293
|
var result;
|
|
3235
3294
|
if (!error && !loading) {
|
|
3236
3295
|
if (mapValues) {
|
|
@@ -3252,7 +3311,7 @@ function mergeLoadingStates() {
|
|
|
3252
3311
|
}
|
|
3253
3312
|
function mapLoadingStateResults(input, config) {
|
|
3254
3313
|
var mapValue = config.mapValue, mapState = config.mapState, _config_alwaysMapValue = config.alwaysMapValue, alwaysMapValue = _config_alwaysMapValue === void 0 ? false : _config_alwaysMapValue;
|
|
3255
|
-
var inputValue = input
|
|
3314
|
+
var inputValue = input.value;
|
|
3256
3315
|
var value;
|
|
3257
3316
|
if ((inputValue != null || alwaysMapValue) && mapValue) {
|
|
3258
3317
|
value = mapValue(inputValue, input);
|
|
@@ -3388,28 +3447,23 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
3388
3447
|
return of(errorResult(error));
|
|
3389
3448
|
}), timeoutStartWith(beginLoading(), 50), shareReplay(1));
|
|
3390
3449
|
}
|
|
3450
|
+
// eslint-disable-next-line jsdoc/require-jsdoc -- JSDoc is on the overload signatures above
|
|
3391
3451
|
function combineLoadingStates() {
|
|
3392
3452
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
3393
3453
|
args[_key] = arguments[_key];
|
|
3394
3454
|
}
|
|
3395
|
-
var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
|
|
3455
|
+
/* eslint-enable @typescript-eslint/max-params */ var validArgs = filterMaybeArrayValues(args); // filter out any undefined values
|
|
3396
3456
|
var lastValueIsMergeFn = typeof validArgs[validArgs.length - 1] === 'function';
|
|
3397
3457
|
var obsArgs = lastValueIsMergeFn ? validArgs.slice(0, validArgs.length - 1) : validArgs;
|
|
3398
3458
|
var mergeFn = lastValueIsMergeFn ? validArgs[validArgs.length - 1] : undefined;
|
|
3399
3459
|
return combineLatest(obsArgs).pipe(distinctUntilChanged(function(x, y) {
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
}) === -1;
|
|
3404
|
-
return hasSameValues;
|
|
3405
|
-
} else {
|
|
3406
|
-
return x === y;
|
|
3407
|
-
}
|
|
3460
|
+
return !x.some(function(_, i) {
|
|
3461
|
+
return x[i] !== y[i];
|
|
3462
|
+
});
|
|
3408
3463
|
}), map(function(states) {
|
|
3409
|
-
|
|
3464
|
+
return mergeLoadingStates.apply(void 0, _to_consumable_array$1(states).concat([
|
|
3410
3465
|
mergeFn
|
|
3411
3466
|
]));
|
|
3412
|
-
return result;
|
|
3413
3467
|
}), shareReplay(1) // Share the result.
|
|
3414
3468
|
);
|
|
3415
3469
|
}
|
|
@@ -3444,7 +3498,7 @@ function combineLoadingStates() {
|
|
|
3444
3498
|
if (firstErrorState) {
|
|
3445
3499
|
result = errorResult(firstErrorState.error);
|
|
3446
3500
|
} else {
|
|
3447
|
-
var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.
|
|
3501
|
+
var oneOrMoreStatesAreCurrentlyLoading = allLoadingStates.some(isLoadingStateLoading);
|
|
3448
3502
|
if (oneOrMoreStatesAreCurrentlyLoading) {
|
|
3449
3503
|
result = beginLoading(); // still loading
|
|
3450
3504
|
} else {
|
|
@@ -3572,7 +3626,7 @@ function tapOnLoadingStateType(fn, type) {
|
|
|
3572
3626
|
};
|
|
3573
3627
|
}
|
|
3574
3628
|
return tap(function(state) {
|
|
3575
|
-
if (
|
|
3629
|
+
if (decisionFunction(state)) {
|
|
3576
3630
|
fn(state);
|
|
3577
3631
|
}
|
|
3578
3632
|
});
|
|
@@ -3724,6 +3778,10 @@ function distinctLoadingState(inputConfig) {
|
|
|
3724
3778
|
*
|
|
3725
3779
|
* Determines the `loading` flag based on whether an error is present, whether the value is defined,
|
|
3726
3780
|
* and the `showLoadingOnUndefinedValue` setting. Loading progress is only included while loading.
|
|
3781
|
+
*
|
|
3782
|
+
* @param state - the current loading state to convert into a context event
|
|
3783
|
+
* @param input - configuration input controlling how the loading flag is derived
|
|
3784
|
+
* @returns a loading state context event derived from the given state
|
|
3727
3785
|
*/ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION(state, input) {
|
|
3728
3786
|
var showLoadingOnUndefinedValue = input.showLoadingOnUndefinedValue;
|
|
3729
3787
|
var error = state.error, value = state.value, loadingProgress = state.loadingProgress;
|
|
@@ -3794,7 +3852,7 @@ function distinctLoadingState(inputConfig) {
|
|
|
3794
3852
|
return result;
|
|
3795
3853
|
}), distinctUntilChanged(isLoadingStateEqual), shareReplay(1));
|
|
3796
3854
|
var currentState$ = currentStateStream$.pipe(switchMap(function(x) {
|
|
3797
|
-
return x ? x : of(undefined);
|
|
3855
|
+
return x !== null && x !== void 0 ? x : of(undefined);
|
|
3798
3856
|
}));
|
|
3799
3857
|
var state$ = currentState$.pipe(filterMaybe(), shareReplay(1));
|
|
3800
3858
|
var loading$ = eventStream$.pipe(map(isLoadingStateLoading));
|
|
@@ -3838,7 +3896,8 @@ function distinctLoadingState(inputConfig) {
|
|
|
3838
3896
|
* @param listLoadingState - the list loading state to check
|
|
3839
3897
|
* @returns true if the value is empty or absent
|
|
3840
3898
|
*/ function isListLoadingStateWithEmptyValue(listLoadingState) {
|
|
3841
|
-
|
|
3899
|
+
var _listLoadingState_value;
|
|
3900
|
+
return Boolean(!((_listLoadingState_value = listLoadingState.value) === null || _listLoadingState_value === void 0 ? void 0 : _listLoadingState_value.length));
|
|
3842
3901
|
}
|
|
3843
3902
|
/**
|
|
3844
3903
|
* RxJS operator that maps each emitted {@link ListLoadingState} to a boolean indicating whether the list is empty.
|
|
@@ -4120,6 +4179,8 @@ function _object_spread_props$3(target, source) {
|
|
|
4120
4179
|
{
|
|
4121
4180
|
/**
|
|
4122
4181
|
* Whether the current state has a non-null error.
|
|
4182
|
+
*
|
|
4183
|
+
* @returns true if the current state contains an error
|
|
4123
4184
|
*/ key: "hasError",
|
|
4124
4185
|
value: function hasError() {
|
|
4125
4186
|
return isLoadingStateWithError(this._subject.value);
|
|
@@ -4612,55 +4673,48 @@ function itemAccumulator(itemIteration, inputMapItem) {
|
|
|
4612
4673
|
return from(asPromise(countResults(allItems)));
|
|
4613
4674
|
})).subscribe({
|
|
4614
4675
|
next: function next(currentResultsCount) {
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
result = _state.sent();
|
|
4631
|
-
currentResultsCount = result.currentCount;
|
|
4632
|
-
return [
|
|
4633
|
-
2,
|
|
4634
|
-
result.shouldContinue
|
|
4635
|
-
];
|
|
4636
|
-
}
|
|
4637
|
-
});
|
|
4638
|
-
})();
|
|
4639
|
-
},
|
|
4640
|
-
next: function next() {
|
|
4641
|
-
return _async_to_generator(function() {
|
|
4642
|
-
return _ts_generator(this, function(_state) {
|
|
4676
|
+
performTaskLoop({
|
|
4677
|
+
initValue: currentResultsCount,
|
|
4678
|
+
checkContinue: function checkContinue(_x, _i) {
|
|
4679
|
+
return _async_to_generator(function() {
|
|
4680
|
+
var result;
|
|
4681
|
+
return _ts_generator(this, function(_state) {
|
|
4682
|
+
switch(_state.label){
|
|
4683
|
+
case 0:
|
|
4684
|
+
return [
|
|
4685
|
+
4,
|
|
4686
|
+
checkResultsLimit()
|
|
4687
|
+
];
|
|
4688
|
+
case 1:
|
|
4689
|
+
result = _state.sent();
|
|
4690
|
+
currentResultsCount = result.currentCount;
|
|
4643
4691
|
return [
|
|
4644
4692
|
2,
|
|
4645
|
-
|
|
4693
|
+
result.shouldContinue
|
|
4646
4694
|
];
|
|
4647
|
-
|
|
4648
|
-
})();
|
|
4649
|
-
}
|
|
4650
|
-
}).then(function(page) {
|
|
4651
|
-
resolve({
|
|
4652
|
-
page: page,
|
|
4653
|
-
resultsCount: currentResultsCount
|
|
4695
|
+
}
|
|
4654
4696
|
});
|
|
4655
|
-
})
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4697
|
+
})();
|
|
4698
|
+
},
|
|
4699
|
+
next: function next() {
|
|
4700
|
+
return _async_to_generator(function() {
|
|
4701
|
+
return _ts_generator(this, function(_state) {
|
|
4702
|
+
return [
|
|
4703
|
+
2,
|
|
4704
|
+
accumulator.itemIteration.nextPage()
|
|
4705
|
+
];
|
|
4706
|
+
});
|
|
4707
|
+
})();
|
|
4708
|
+
}
|
|
4709
|
+
}).then(function(page) {
|
|
4710
|
+
resolve({
|
|
4711
|
+
page: page,
|
|
4712
|
+
resultsCount: currentResultsCount
|
|
4662
4713
|
});
|
|
4663
|
-
})()
|
|
4714
|
+
}).catch(function(error) {
|
|
4715
|
+
reject(error);
|
|
4716
|
+
throw error;
|
|
4717
|
+
});
|
|
4664
4718
|
},
|
|
4665
4719
|
error: function error(error) {
|
|
4666
4720
|
reject(error);
|
|
@@ -5159,11 +5213,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5159
5213
|
hasNextPage: invertMaybeBoolean(end)
|
|
5160
5214
|
});
|
|
5161
5215
|
}
|
|
5162
|
-
|
|
5216
|
+
return {
|
|
5163
5217
|
n: request.n,
|
|
5164
5218
|
state: state
|
|
5165
5219
|
};
|
|
5166
|
-
return result;
|
|
5167
5220
|
}));
|
|
5168
5221
|
}), scan(function(acc, x) {
|
|
5169
5222
|
var n = x.n, curr = x.state;
|
|
@@ -5176,19 +5229,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5176
5229
|
lastSuccessful: acc.lastSuccessful
|
|
5177
5230
|
};
|
|
5178
5231
|
// If it was a replay of the previous result, change nothing.
|
|
5179
|
-
if (acc.current !== curr) {
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
if (!next.firstSuccessful) {
|
|
5189
|
-
next.firstSuccessful = curr;
|
|
5190
|
-
}
|
|
5191
|
-
}
|
|
5232
|
+
if (acc.current !== curr && isLoadingStateFinishedLoading(curr)) {
|
|
5233
|
+
var // only set first finished once
|
|
5234
|
+
_next, _firstFinished;
|
|
5235
|
+
(_firstFinished = (_next = next).firstFinished) !== null && _firstFinished !== void 0 ? _firstFinished : _next.firstFinished = curr;
|
|
5236
|
+
next.latestFinished = curr;
|
|
5237
|
+
if (!isLoadingStateWithError(curr)) {
|
|
5238
|
+
var _next1, _firstSuccessful;
|
|
5239
|
+
next.lastSuccessful = curr;
|
|
5240
|
+
(_firstSuccessful = (_next1 = next).firstSuccessful) !== null && _firstSuccessful !== void 0 ? _firstSuccessful : _next1.firstSuccessful = curr;
|
|
5192
5241
|
}
|
|
5193
5242
|
}
|
|
5194
5243
|
return next;
|
|
@@ -5497,6 +5546,10 @@ function _type_of(obj) {
|
|
|
5497
5546
|
* Useful for deferring an action until all locks are released, with a safety timeout to avoid waiting indefinitely.
|
|
5498
5547
|
*
|
|
5499
5548
|
* @param config - configuration specifying the lock set, callback, timeout, and optional delay
|
|
5549
|
+
* @param config.lockSet - the lock set to monitor for the next unlock event
|
|
5550
|
+
* @param config.fn - optional callback to invoke when the lock set unlocks or the timeout is reached
|
|
5551
|
+
* @param config.timeout - maximum time in milliseconds to wait before timing out
|
|
5552
|
+
* @param config.delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
5500
5553
|
* @returns subscription that can be unsubscribed to cancel the wait
|
|
5501
5554
|
*
|
|
5502
5555
|
* @example
|
|
@@ -5924,14 +5977,14 @@ function _define_property(obj, key, value) {
|
|
|
5924
5977
|
*
|
|
5925
5978
|
* If the loading state returns an error, the error is forwarded.
|
|
5926
5979
|
*
|
|
5927
|
-
* @param loadingStateObs
|
|
5980
|
+
* @param loadingStateObs - observable of the loading state to track as the work result
|
|
5928
5981
|
*/ key: "startWorkingWithLoadingStateObservable",
|
|
5929
5982
|
value: function startWorkingWithLoadingStateObservable(loadingStateObs) {
|
|
5930
5983
|
var _this = this;
|
|
5931
5984
|
var obs = preventComplete(loadingStateObs).pipe(filterMaybe(), shareReplay(1));
|
|
5932
5985
|
this._sub.subscription = obs.pipe(delay(0), first()).subscribe(function() {
|
|
5933
5986
|
_this.startWorkingWithObservable(obs.pipe(filter(function(x) {
|
|
5934
|
-
return
|
|
5987
|
+
return !isLoadingStateLoading(x);
|
|
5935
5988
|
}), map(function(x) {
|
|
5936
5989
|
if (x.error) {
|
|
5937
5990
|
throw x.error;
|
|
@@ -5950,11 +6003,12 @@ function _define_property(obj, key, value) {
|
|
|
5950
6003
|
*
|
|
5951
6004
|
* It is used in conjunction with startWorking() and ideal for cases where multiple observables or promises are used.
|
|
5952
6005
|
*
|
|
5953
|
-
* @param loadingStateObs
|
|
6006
|
+
* @param loadingStateObs - promise or observable of the loading state to track for errors
|
|
6007
|
+
* @returns a promise that resolves with the value from the loading state or rejects on error
|
|
5954
6008
|
*/ key: "performTaskWithLoadingState",
|
|
5955
6009
|
value: function performTaskWithLoadingState(loadingStateObs) {
|
|
5956
6010
|
var _this = this;
|
|
5957
|
-
return promiseFromLoadingState(from(loadingStateObs).pipe(filterMaybe(), tap(function(
|
|
6011
|
+
return promiseFromLoadingState(from(loadingStateObs).pipe(filterMaybe(), tap(function(_x) {
|
|
5958
6012
|
_this._setWorking(true); // mark as working if not already marked.
|
|
5959
6013
|
}))).catch(function(e) {
|
|
5960
6014
|
// catch and throw any errors.
|
|
@@ -5969,7 +6023,7 @@ function _define_property(obj, key, value) {
|
|
|
5969
6023
|
*
|
|
5970
6024
|
* If an error is thrown, the error is forwarded to the reject function.
|
|
5971
6025
|
*
|
|
5972
|
-
* @param fn
|
|
6026
|
+
* @param fn - synchronous function that returns the result value or throws an error
|
|
5973
6027
|
*/ key: "performTaskWithReturnValue",
|
|
5974
6028
|
value: function performTaskWithReturnValue(fn) {
|
|
5975
6029
|
try {
|
|
@@ -5984,6 +6038,8 @@ function _define_property(obj, key, value) {
|
|
|
5984
6038
|
{
|
|
5985
6039
|
/**
|
|
5986
6040
|
* Begins working using a promise.
|
|
6041
|
+
*
|
|
6042
|
+
* @param promise - the promise that represents the asynchronous work
|
|
5987
6043
|
*/ key: "startWorkingWithPromise",
|
|
5988
6044
|
value: function startWorkingWithPromise(promise) {
|
|
5989
6045
|
this.startWorkingWithObservable(from(promise));
|
|
@@ -5992,6 +6048,8 @@ function _define_property(obj, key, value) {
|
|
|
5992
6048
|
{
|
|
5993
6049
|
/**
|
|
5994
6050
|
* Begins working using an observable.
|
|
6051
|
+
*
|
|
6052
|
+
* @param workObs - the observable that represents the asynchronous work and emits the result
|
|
5995
6053
|
*/ key: "startWorkingWithObservable",
|
|
5996
6054
|
value: function startWorkingWithObservable(workObs) {
|
|
5997
6055
|
var _this = this;
|
|
@@ -6018,6 +6076,8 @@ function _define_property(obj, key, value) {
|
|
|
6018
6076
|
{
|
|
6019
6077
|
/**
|
|
6020
6078
|
* Sets success on the work.
|
|
6079
|
+
*
|
|
6080
|
+
* @param result - the successful result value to pass to the delegate
|
|
6021
6081
|
*/ key: "success",
|
|
6022
6082
|
value: function success(result) {
|
|
6023
6083
|
this._setComplete(successResult(result));
|
|
@@ -6027,6 +6087,8 @@ function _define_property(obj, key, value) {
|
|
|
6027
6087
|
{
|
|
6028
6088
|
/**
|
|
6029
6089
|
* Sets rejected on the work.
|
|
6090
|
+
*
|
|
6091
|
+
* @param error - the error to pass to the delegate as the rejection reason
|
|
6030
6092
|
*/ key: "reject",
|
|
6031
6093
|
value: function reject(error) {
|
|
6032
6094
|
this._setComplete(errorResult(error));
|
|
@@ -6088,6 +6150,8 @@ function _define_property(obj, key, value) {
|
|
|
6088
6150
|
* ```
|
|
6089
6151
|
*
|
|
6090
6152
|
* @param config - work function and delegate configuration
|
|
6153
|
+
* @param config.work - the work function to execute for each input value
|
|
6154
|
+
* @param config.delegate - delegate that receives lifecycle callbacks (start, success, reject)
|
|
6091
6155
|
* @returns a factory function that creates WorkInstance for each input
|
|
6092
6156
|
*/ function workFactory(param) {
|
|
6093
6157
|
var work = param.work, delegate = param.delegate;
|
|
@@ -6101,13 +6165,11 @@ function _define_property(obj, key, value) {
|
|
|
6101
6165
|
handler.reject(e);
|
|
6102
6166
|
return;
|
|
6103
6167
|
}
|
|
6104
|
-
if (!handler.isComplete) {
|
|
6105
|
-
if (
|
|
6106
|
-
|
|
6107
|
-
throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
|
|
6108
|
-
}
|
|
6109
|
-
handler.startWorkingWithObservable(fnResult);
|
|
6168
|
+
if (!handler.isComplete && fnResult && isObservable(fnResult)) {
|
|
6169
|
+
if (handler.hasStarted) {
|
|
6170
|
+
throw new Error('Work already marked as begun from returned result. Either return an observable or use the handler directly.');
|
|
6110
6171
|
}
|
|
6172
|
+
handler.startWorkingWithObservable(fnResult);
|
|
6111
6173
|
}
|
|
6112
6174
|
return handler;
|
|
6113
6175
|
};
|