@dereekb/rxjs 13.0.7 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1284 -336
- package/index.cjs.js.map +1 -1
- package/index.esm.js +1284 -336
- package/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/filter/filter.d.ts +28 -13
- package/src/lib/filter/filter.map.d.ts +69 -2
- package/src/lib/filter/filter.preset.d.ts +35 -0
- package/src/lib/filter/filter.source.d.ts +61 -2
- package/src/lib/iterator/iteration.accumulator.d.ts +39 -13
- package/src/lib/iterator/iteration.accumulator.rxjs.d.ts +25 -8
- package/src/lib/iterator/iteration.d.ts +16 -5
- package/src/lib/iterator/iteration.mapped.d.ts +19 -6
- package/src/lib/iterator/iteration.mapped.page.d.ts +9 -6
- package/src/lib/iterator/iteration.next.d.ts +17 -14
- package/src/lib/iterator/iterator.page.d.ts +54 -16
- package/src/lib/loading/loading.context.rxjs.d.ts +17 -1
- package/src/lib/loading/loading.context.simple.d.ts +38 -1
- package/src/lib/loading/loading.context.state.d.ts +32 -4
- package/src/lib/loading/loading.context.state.list.d.ts +25 -3
- package/src/lib/loading/loading.context.value.d.ts +43 -3
- package/src/lib/loading/loading.state.d.ts +272 -41
- package/src/lib/loading/loading.state.list.d.ts +50 -9
- package/src/lib/lock.d.ts +149 -6
- package/src/lib/object.d.ts +28 -4
- package/src/lib/rxjs/array.d.ts +39 -13
- package/src/lib/rxjs/boolean.d.ts +8 -4
- package/src/lib/rxjs/decision.d.ts +13 -7
- package/src/lib/rxjs/delta.d.ts +14 -2
- package/src/lib/rxjs/expires.d.ts +20 -8
- package/src/lib/rxjs/factory.d.ts +16 -3
- package/src/lib/rxjs/getter.d.ts +24 -10
- package/src/lib/rxjs/key.d.ts +7 -5
- package/src/lib/rxjs/lifecycle.d.ts +10 -7
- package/src/lib/rxjs/loading.d.ts +10 -2
- package/src/lib/rxjs/map.d.ts +6 -5
- package/src/lib/rxjs/misc.d.ts +26 -6
- package/src/lib/rxjs/model.d.ts +2 -2
- package/src/lib/rxjs/number.d.ts +8 -4
- package/src/lib/rxjs/rxjs.async.d.ts +20 -7
- package/src/lib/rxjs/rxjs.d.ts +26 -18
- package/src/lib/rxjs/rxjs.error.d.ts +17 -0
- package/src/lib/rxjs/rxjs.map.d.ts +37 -9
- package/src/lib/rxjs/rxjs.unique.d.ts +6 -3
- package/src/lib/rxjs/set.d.ts +34 -0
- package/src/lib/rxjs/string.d.ts +18 -1
- package/src/lib/rxjs/timeout.d.ts +21 -1
- package/src/lib/rxjs/use.d.ts +4 -2
- package/src/lib/rxjs/value.d.ts +73 -39
- package/src/lib/subscription.d.ts +80 -3
- package/src/lib/work/work.factory.d.ts +42 -9
- package/src/lib/work/work.instance.d.ts +26 -2
package/index.esm.js
CHANGED
|
@@ -9,18 +9,19 @@ function asObservable(valueOrObs) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* RxJS operator that flattens an emitted {@link ObservableOrValue} into its unwrapped value via `switchMap`.
|
|
13
13
|
*
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns an operator that unwraps ObservableOrValue emissions
|
|
15
15
|
*/ function valueFromObservableOrValue() {
|
|
16
16
|
return switchMap(function(x) {
|
|
17
17
|
return asObservable(x);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* RxJS operator that flattens an emitted Maybe<{@link ObservableOrValue}> into its unwrapped value,
|
|
22
|
+
* emitting `undefined` when the input is nullish.
|
|
22
23
|
*
|
|
23
|
-
* @returns
|
|
24
|
+
* @returns an operator that unwraps Maybe<ObservableOrValue> emissions
|
|
24
25
|
*/ function maybeValueFromObservableOrValue() {
|
|
25
26
|
return switchMap(function(x) {
|
|
26
27
|
return x != null ? asObservable(x) : of(undefined);
|
|
@@ -31,15 +32,18 @@ function asObservableFromGetter(input, args) {
|
|
|
31
32
|
return asObservable(obs);
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* RxJS operator that flattens an emitted {@link ObservableOrValueGetter} into its resolved value via `switchMap`.
|
|
35
36
|
*
|
|
36
|
-
* @returns
|
|
37
|
+
* @returns an operator that unwraps getter emissions
|
|
37
38
|
*/ function valueFromObservableOrValueGetter() {
|
|
38
39
|
return switchMap(function(x) {
|
|
39
40
|
return asObservableFromGetter(x);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* RxJS operator that flattens an emitted Maybe<{@link ObservableOrValueGetter}> into its resolved value,
|
|
45
|
+
* emitting `undefined` when the input is nullish.
|
|
46
|
+
*/ function maybeValueFromObservableOrValueGetter() {
|
|
43
47
|
return switchMap(function(x) {
|
|
44
48
|
return x != null ? asObservableFromGetter(x) : of(undefined);
|
|
45
49
|
});
|
|
@@ -95,9 +99,10 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
95
99
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
98
|
-
* Creates an IsModifiedFunction
|
|
102
|
+
* Creates an {@link IsModifiedFunction} by inverting the result of an {@link IsEqualFunction}.
|
|
99
103
|
*
|
|
100
|
-
* @param isEqualFunction
|
|
104
|
+
* @param isEqualFunction - equality check function to invert
|
|
105
|
+
* @returns a function that returns true when the value has been modified
|
|
101
106
|
*/ function makeIsModifiedFunction(isEqualFunction) {
|
|
102
107
|
return function(value) {
|
|
103
108
|
return isEqualFunction(value).pipe(map(function(x) {
|
|
@@ -106,10 +111,13 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
106
111
|
};
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
|
-
* Creates an
|
|
114
|
+
* Creates an observable that emits an {@link IsModifiedFunction} derived from the config.
|
|
110
115
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
116
|
+
* Prefers `isModified` over `isEqual` (which is inverted), falling back to `defaultFunction`
|
|
117
|
+
* or a function that always returns true.
|
|
118
|
+
*
|
|
119
|
+
* @param config - configuration with isModified, isEqual, and/or defaultFunction
|
|
120
|
+
* @returns an observable of the resolved IsModifiedFunction
|
|
113
121
|
*/ function makeIsModifiedFunctionObservable(config) {
|
|
114
122
|
var isModified = config.isModified, isEqual = config.isEqual, defaultFunction = config.defaultFunction;
|
|
115
123
|
return combineLatest([
|
|
@@ -124,29 +132,53 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
124
132
|
}));
|
|
125
133
|
}
|
|
126
134
|
// MARK: IsCheck
|
|
127
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Creates a function that returns the value if the check function returns true, otherwise undefined.
|
|
137
|
+
*
|
|
138
|
+
* @param isCheckFunction - optional check function
|
|
139
|
+
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
140
|
+
*/ function makeReturnIfIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
128
141
|
return function(value) {
|
|
129
142
|
return returnIfIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
130
143
|
};
|
|
131
144
|
}
|
|
132
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Returns the value wrapped in an observable if the check function passes, otherwise emits undefined.
|
|
147
|
+
*
|
|
148
|
+
* @param isCheckFunction - optional check function
|
|
149
|
+
* @param value - the value to check
|
|
150
|
+
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
151
|
+
*/ function returnIfIs(isCheckFunction, value, defaultValueOnMaybe) {
|
|
133
152
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe).pipe(map(function(x) {
|
|
134
153
|
return x ? value : undefined;
|
|
135
154
|
}));
|
|
136
155
|
}
|
|
137
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Creates a function that checks a value against the check function and returns an observable boolean.
|
|
158
|
+
*
|
|
159
|
+
* @param isCheckFunction - optional check function
|
|
160
|
+
* @param defaultValueOnMaybe - default result for null/undefined values
|
|
161
|
+
*/ function makeCheckIsFunction(isCheckFunction, defaultValueOnMaybe) {
|
|
138
162
|
return function(value) {
|
|
139
163
|
return checkIs(isCheckFunction, value, defaultValueOnMaybe);
|
|
140
164
|
};
|
|
141
165
|
}
|
|
142
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Evaluates a value against an optional check function, returning an observable boolean.
|
|
168
|
+
*
|
|
169
|
+
* Returns `of(true)` when no check function is provided.
|
|
170
|
+
*
|
|
171
|
+
* @param isCheckFunction - optional check function
|
|
172
|
+
* @param value - the value to check
|
|
173
|
+
* @param defaultValueOnMaybe - default result for null/undefined values (defaults to false)
|
|
174
|
+
*/ function checkIs(isCheckFunction, value) {
|
|
143
175
|
var defaultValueOnMaybe = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
144
176
|
var is = isCheckFunction ? value != null ? isCheckFunction(value) : of(defaultValueOnMaybe) : of(true);
|
|
145
177
|
return is;
|
|
146
178
|
}
|
|
147
179
|
// MARK: Filter
|
|
148
180
|
/**
|
|
149
|
-
*
|
|
181
|
+
* RxJS operator that filters out null and undefined values, only passing through defined values.
|
|
150
182
|
*/ function filterMaybe() {
|
|
151
183
|
return filter(isMaybeSo);
|
|
152
184
|
}
|
|
@@ -154,34 +186,36 @@ function checkIs(isCheckFunction, value) {
|
|
|
154
186
|
* Equivalent to filterMaybe, but returns a strict MaybeSoStrict<T> value instead of the template type.
|
|
155
187
|
*/ var filterMaybeStrict = filterMaybe;
|
|
156
188
|
/**
|
|
157
|
-
*
|
|
189
|
+
* RxJS operator that filters out null/undefined elements from an emitted array, keeping only defined values.
|
|
158
190
|
*/ function filterMaybeArray() {
|
|
159
191
|
return map(filterMaybeArrayValues);
|
|
160
192
|
}
|
|
161
193
|
/**
|
|
162
|
-
*
|
|
194
|
+
* RxJS operator that skips all leading null/undefined emissions, then passes all subsequent values through.
|
|
163
195
|
*/ function skipAllInitialMaybe() {
|
|
164
196
|
return skipWhile(function(x) {
|
|
165
197
|
return x == null;
|
|
166
198
|
});
|
|
167
199
|
}
|
|
168
200
|
/**
|
|
169
|
-
*
|
|
201
|
+
* RxJS operator that skips only the first emission if it is null/undefined, then passes all subsequent values.
|
|
170
202
|
*/ function skipInitialMaybe() {
|
|
171
203
|
return skipMaybes(1);
|
|
172
204
|
}
|
|
173
205
|
/**
|
|
174
|
-
*
|
|
206
|
+
* RxJS operator that skips up to `maxToSkip` null/undefined emissions, then passes all subsequent values.
|
|
207
|
+
*
|
|
208
|
+
* @param maxToSkip - maximum number of null/undefined emissions to skip
|
|
175
209
|
*/ function skipMaybes(maxToSkip) {
|
|
176
210
|
return skipWhile(function(x, i) {
|
|
177
211
|
return x == null && i < maxToSkip;
|
|
178
212
|
});
|
|
179
213
|
}
|
|
180
214
|
/**
|
|
181
|
-
*
|
|
215
|
+
* RxJS operator that switches to the emitted observable if defined, or emits the default value if null/undefined.
|
|
182
216
|
*
|
|
183
|
-
* @param defaultValue
|
|
184
|
-
* @returns
|
|
217
|
+
* @param defaultValue - fallback value when the observable is nullish (defaults to undefined)
|
|
218
|
+
* @returns an operator that handles optional observables
|
|
185
219
|
*/ function switchMapMaybeDefault() {
|
|
186
220
|
var defaultValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : undefined;
|
|
187
221
|
return switchMap(function(x) {
|
|
@@ -207,7 +241,8 @@ function switchMapToDefault(defaultObs, useDefault) {
|
|
|
207
241
|
});
|
|
208
242
|
}
|
|
209
243
|
/**
|
|
210
|
-
*
|
|
244
|
+
* RxJS operator that resolves an observable/getter config input into a value, applying defaults
|
|
245
|
+
* for `null`/`undefined`/`true` inputs and emitting `null` for `false`.
|
|
211
246
|
*/ function switchMapObject(config) {
|
|
212
247
|
var defaultGetter = config.defaultGetter;
|
|
213
248
|
return switchMap(function(inputConfig) {
|
|
@@ -239,9 +274,9 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
239
274
|
});
|
|
240
275
|
}
|
|
241
276
|
/**
|
|
242
|
-
*
|
|
277
|
+
* RxJS operator that filters out null/undefined observables and then switches to the remaining ones.
|
|
243
278
|
*
|
|
244
|
-
* @
|
|
279
|
+
* Combines {@link filterMaybe} and `switchMap` to only subscribe to non-nullish observables.
|
|
245
280
|
*/ function switchMapFilterMaybe() {
|
|
246
281
|
return function(source) {
|
|
247
282
|
var subscriber = source.pipe(filterMaybe(), switchMap(function(x) {
|
|
@@ -251,9 +286,7 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
251
286
|
};
|
|
252
287
|
}
|
|
253
288
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* @returns
|
|
289
|
+
* RxJS operator that switches to the emitted observable if defined, or emits `undefined` when the observable is nullish.
|
|
257
290
|
*/ function switchMapMaybe() {
|
|
258
291
|
return function(source) {
|
|
259
292
|
var subscriber = source.pipe(switchMap(function(x) {
|
|
@@ -263,18 +296,19 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
263
296
|
};
|
|
264
297
|
}
|
|
265
298
|
/**
|
|
266
|
-
*
|
|
299
|
+
* RxJS operator that applies a map function only when the emitted value is non-null/non-undefined.
|
|
267
300
|
*
|
|
268
|
-
* @param mapFn
|
|
269
|
-
* @returns
|
|
301
|
+
* @param mapFn - function to transform defined values
|
|
302
|
+
* @returns an operator that maps defined values and passes through undefined
|
|
270
303
|
*/ function mapMaybe(mapFn) {
|
|
271
304
|
return mapIf(mapFn, isMaybeSo);
|
|
272
305
|
}
|
|
273
306
|
/**
|
|
274
|
-
*
|
|
307
|
+
* RxJS operator that applies a map function only when the decision function returns true.
|
|
275
308
|
*
|
|
276
|
-
* @param mapFn
|
|
277
|
-
* @
|
|
309
|
+
* @param mapFn - function to transform the value
|
|
310
|
+
* @param decision - predicate that determines whether to apply the map
|
|
311
|
+
* @returns an operator that conditionally maps values
|
|
278
312
|
*/ function mapIf(mapFn, decision) {
|
|
279
313
|
return map(function(x) {
|
|
280
314
|
return decision(x) ? mapFn(x) : undefined;
|
|
@@ -319,9 +353,20 @@ function switchMapOnBoolean(switchOnValue, obs, otherwise) {
|
|
|
319
353
|
}
|
|
320
354
|
|
|
321
355
|
/**
|
|
322
|
-
*
|
|
356
|
+
* RxJS operator that suppresses consecutive emissions when the emitted POJO values are deeply equal.
|
|
357
|
+
*
|
|
358
|
+
* Uses {@link areEqualPOJOValues} for comparison, so the emitted objects should be plain objects
|
|
359
|
+
* or compatible with deep value equality checks.
|
|
323
360
|
*
|
|
324
|
-
*
|
|
361
|
+
* @returns operator that filters out consecutive duplicate POJO emissions
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* of({ a: 1 }, { a: 1 }, { a: 2 }).pipe(
|
|
366
|
+
* distinctUntilObjectValuesChanged()
|
|
367
|
+
* ).subscribe(console.log);
|
|
368
|
+
* // Output: { a: 1 }, { a: 2 }
|
|
369
|
+
* ```
|
|
325
370
|
*/ function distinctUntilObjectValuesChanged() {
|
|
326
371
|
return distinctUntilChanged(function(a, b) {
|
|
327
372
|
return areEqualPOJOValues(a, b);
|
|
@@ -396,7 +441,22 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
396
441
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
|
|
397
442
|
}
|
|
398
443
|
/**
|
|
399
|
-
*
|
|
444
|
+
* Manages a single RxJS subscription with automatic cleanup on reassignment.
|
|
445
|
+
*
|
|
446
|
+
* When a new subscription is assigned, the previous one is automatically unsubscribed.
|
|
447
|
+
* Implements {@link Destroyable} for integration with lifecycle management patterns.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* const sub = new SubscriptionObject();
|
|
452
|
+
*
|
|
453
|
+
* // Assign a subscription — previous one is automatically unsubscribed
|
|
454
|
+
* sub.subscription = interval(1000).subscribe(console.log);
|
|
455
|
+
* sub.subscription = interval(500).subscribe(console.log); // first subscription is cleaned up
|
|
456
|
+
*
|
|
457
|
+
* // Clean up when done
|
|
458
|
+
* sub.destroy();
|
|
459
|
+
* ```
|
|
400
460
|
*/ var SubscriptionObject = /*#__PURE__*/ function() {
|
|
401
461
|
function SubscriptionObject(sub) {
|
|
402
462
|
_class_call_check$8(this, SubscriptionObject);
|
|
@@ -408,25 +468,35 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
408
468
|
_create_class$7(SubscriptionObject, [
|
|
409
469
|
{
|
|
410
470
|
key: "hasSubscription",
|
|
411
|
-
get:
|
|
471
|
+
get: /**
|
|
472
|
+
* Whether a subscription is currently being managed.
|
|
473
|
+
*/ function get() {
|
|
412
474
|
return Boolean(this._subscription);
|
|
413
475
|
}
|
|
414
476
|
},
|
|
415
477
|
{
|
|
416
478
|
key: "subscription",
|
|
417
|
-
set:
|
|
479
|
+
set: /**
|
|
480
|
+
* Sets the managed subscription, unsubscribing from any previous one.
|
|
481
|
+
*/ function set(sub) {
|
|
418
482
|
this.setSub(sub);
|
|
419
483
|
}
|
|
420
484
|
},
|
|
421
485
|
{
|
|
422
|
-
|
|
486
|
+
/**
|
|
487
|
+
* Replaces the current subscription with the given one, unsubscribing from the previous.
|
|
488
|
+
*
|
|
489
|
+
* @param sub - new subscription to manage, or `undefined`/`void` to just unsubscribe
|
|
490
|
+
*/ key: "setSub",
|
|
423
491
|
value: function setSub(sub) {
|
|
424
492
|
this.unsub();
|
|
425
493
|
this._subscription = sub;
|
|
426
494
|
}
|
|
427
495
|
},
|
|
428
496
|
{
|
|
429
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Unsubscribes from the current subscription, if any.
|
|
499
|
+
*/ key: "unsub",
|
|
430
500
|
value: function unsub() {
|
|
431
501
|
if (this._subscription) {
|
|
432
502
|
this._subscription.unsubscribe();
|
|
@@ -435,7 +505,9 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
435
505
|
}
|
|
436
506
|
},
|
|
437
507
|
{
|
|
438
|
-
|
|
508
|
+
/**
|
|
509
|
+
* Unsubscribes from the current subscription and releases the reference.
|
|
510
|
+
*/ key: "destroy",
|
|
439
511
|
value: function destroy() {
|
|
440
512
|
this.unsub();
|
|
441
513
|
}
|
|
@@ -444,9 +516,26 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
444
516
|
return SubscriptionObject;
|
|
445
517
|
}();
|
|
446
518
|
/**
|
|
447
|
-
*
|
|
519
|
+
* Manages multiple RxJS subscriptions as a group, with bulk unsubscribe and cleanup.
|
|
520
|
+
*
|
|
521
|
+
* Useful when multiple independent subscriptions share a lifecycle. For subscriptions that
|
|
522
|
+
* should be merged into a single stream, consider using RxJS `merge(...)` instead.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* const subs = new MultiSubscriptionObject();
|
|
527
|
+
*
|
|
528
|
+
* subs.subscriptions = [
|
|
529
|
+
* source1$.subscribe(console.log),
|
|
530
|
+
* source2$.subscribe(console.log)
|
|
531
|
+
* ];
|
|
448
532
|
*
|
|
449
|
-
*
|
|
533
|
+
* // Add more subscriptions later
|
|
534
|
+
* subs.addSubs(source3$.subscribe(console.log));
|
|
535
|
+
*
|
|
536
|
+
* // Clean up all at once
|
|
537
|
+
* subs.destroy();
|
|
538
|
+
* ```
|
|
450
539
|
*/ var MultiSubscriptionObject = /*#__PURE__*/ function() {
|
|
451
540
|
function MultiSubscriptionObject(subs) {
|
|
452
541
|
_class_call_check$8(this, MultiSubscriptionObject);
|
|
@@ -458,26 +547,38 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
458
547
|
_create_class$7(MultiSubscriptionObject, [
|
|
459
548
|
{
|
|
460
549
|
key: "hasSubscription",
|
|
461
|
-
get:
|
|
550
|
+
get: /**
|
|
551
|
+
* Whether any subscriptions are currently being managed.
|
|
552
|
+
*/ function get() {
|
|
462
553
|
var _this__subscriptions;
|
|
463
554
|
return Boolean((_this__subscriptions = this._subscriptions) === null || _this__subscriptions === void 0 ? void 0 : _this__subscriptions.length);
|
|
464
555
|
}
|
|
465
556
|
},
|
|
466
557
|
{
|
|
467
558
|
key: "subscriptions",
|
|
468
|
-
set:
|
|
559
|
+
set: /**
|
|
560
|
+
* Replaces all managed subscriptions, unsubscribing from previous ones.
|
|
561
|
+
*/ function set(subs) {
|
|
469
562
|
this.setSubs(subs);
|
|
470
563
|
}
|
|
471
564
|
},
|
|
472
565
|
{
|
|
473
|
-
|
|
566
|
+
/**
|
|
567
|
+
* Replaces all managed subscriptions with the given ones, unsubscribing from all previous.
|
|
568
|
+
*
|
|
569
|
+
* @param subs - new subscription(s) to manage
|
|
570
|
+
*/ key: "setSubs",
|
|
474
571
|
value: function setSubs(subs) {
|
|
475
572
|
this.unsub();
|
|
476
573
|
this._subscriptions = convertToArray(subs);
|
|
477
574
|
}
|
|
478
575
|
},
|
|
479
576
|
{
|
|
480
|
-
|
|
577
|
+
/**
|
|
578
|
+
* Adds subscription(s) to the managed set without affecting existing ones. Duplicate subscriptions are ignored.
|
|
579
|
+
*
|
|
580
|
+
* @param subs - subscription(s) to add
|
|
581
|
+
*/ key: "addSubs",
|
|
481
582
|
value: function addSubs(subs) {
|
|
482
583
|
var _this__subscriptions;
|
|
483
584
|
var nextSubscriptions = _to_consumable_array$5((_this__subscriptions = this._subscriptions) !== null && _this__subscriptions !== void 0 ? _this__subscriptions : []);
|
|
@@ -490,7 +591,9 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
490
591
|
}
|
|
491
592
|
},
|
|
492
593
|
{
|
|
493
|
-
|
|
594
|
+
/**
|
|
595
|
+
* Unsubscribes from all managed subscriptions and clears the list.
|
|
596
|
+
*/ key: "unsub",
|
|
494
597
|
value: function unsub() {
|
|
495
598
|
if (this._subscriptions) {
|
|
496
599
|
this._subscriptions.forEach(function(x) {
|
|
@@ -501,7 +604,9 @@ function _unsupported_iterable_to_array$a(o, minLen) {
|
|
|
501
604
|
}
|
|
502
605
|
},
|
|
503
606
|
{
|
|
504
|
-
|
|
607
|
+
/**
|
|
608
|
+
* Unsubscribes from all managed subscriptions and releases references.
|
|
609
|
+
*/ key: "destroy",
|
|
505
610
|
value: function destroy() {
|
|
506
611
|
this.unsub();
|
|
507
612
|
}
|
|
@@ -589,7 +694,27 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
589
694
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
|
|
590
695
|
}
|
|
591
696
|
/**
|
|
592
|
-
*
|
|
697
|
+
* Concrete implementation of {@link FilterSource} that manages reactive filter state with
|
|
698
|
+
* support for default values, initial values, and explicit overrides.
|
|
699
|
+
*
|
|
700
|
+
* Filter priority (highest to lowest):
|
|
701
|
+
* 1. Explicit filter set via {@link setFilter}
|
|
702
|
+
* 2. Initial filter set via {@link initWithFilter}
|
|
703
|
+
* 3. Default filter set via {@link setDefaultFilter}
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```ts
|
|
707
|
+
* const source = new FilterSourceInstance<{ active: boolean }>();
|
|
708
|
+
*
|
|
709
|
+
* // Set a default filter
|
|
710
|
+
* source.setDefaultFilter(of({ active: false }));
|
|
711
|
+
*
|
|
712
|
+
* // Override with an explicit filter
|
|
713
|
+
* source.setFilter({ active: true });
|
|
714
|
+
*
|
|
715
|
+
* // Reset back to default
|
|
716
|
+
* source.resetFilter();
|
|
717
|
+
* ```
|
|
593
718
|
*/ var FilterSourceInstance = /*#__PURE__*/ function() {
|
|
594
719
|
function FilterSourceInstance(config) {
|
|
595
720
|
var _this = this;
|
|
@@ -601,8 +726,12 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
601
726
|
* The initial filter can only pass through observables that always emit a value.
|
|
602
727
|
*/ _define_property$b(this, "_initialFilter", new BehaviorSubject(undefined));
|
|
603
728
|
_define_property$b(this, "_defaultFilter", new BehaviorSubject(undefined));
|
|
604
|
-
|
|
605
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Observable of the default filter value, emitting when a default is set.
|
|
731
|
+
*/ _define_property$b(this, "defaultFilter$", this._defaultFilter.pipe(switchMapFilterMaybe()));
|
|
732
|
+
/**
|
|
733
|
+
* Observable that emits the initial filter value, preferring the init filter over the default.
|
|
734
|
+
*/ _define_property$b(this, "initialFilter$", combineLatest([
|
|
606
735
|
this._initialFilter,
|
|
607
736
|
this._defaultFilter
|
|
608
737
|
]).pipe(map(function(param) {
|
|
@@ -610,7 +739,8 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
610
739
|
return a !== null && a !== void 0 ? a : b;
|
|
611
740
|
}), switchMapFilterMaybe(), distinctUntilChanged(), shareReplay(1)));
|
|
612
741
|
/**
|
|
613
|
-
*
|
|
742
|
+
* Observable of the active filter value, resolving to the explicit filter if set,
|
|
743
|
+
* otherwise falling back to the initial/default filter. Deduplicated by deep value equality.
|
|
614
744
|
*/ _define_property$b(this, "filter$", this._filter.pipe(switchMap(function(x) {
|
|
615
745
|
return x != null ? of(x) : _this.initialFilter$;
|
|
616
746
|
}), filterMaybe(), distinctUntilObjectValuesChanged(), shareReplay(1)));
|
|
@@ -627,20 +757,32 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
627
757
|
}
|
|
628
758
|
_create_class$6(FilterSourceInstance, [
|
|
629
759
|
{
|
|
630
|
-
|
|
760
|
+
/**
|
|
761
|
+
* Sets an initial filter observable that takes priority over the default filter.
|
|
762
|
+
*
|
|
763
|
+
* @param filterObs - observable providing the initial filter value
|
|
764
|
+
*/ key: "initWithFilter",
|
|
631
765
|
value: function initWithFilter(filterObs) {
|
|
632
766
|
this._initialFilter.next(filterObs);
|
|
633
767
|
this.initFilterTakesPriority();
|
|
634
768
|
}
|
|
635
769
|
},
|
|
636
770
|
{
|
|
637
|
-
|
|
771
|
+
/**
|
|
772
|
+
* Sets the default filter, used as a fallback when no explicit or initial filter is active.
|
|
773
|
+
*
|
|
774
|
+
* @param filter - default filter value, observable, or undefined to clear
|
|
775
|
+
*/ key: "setDefaultFilter",
|
|
638
776
|
value: function setDefaultFilter(filter) {
|
|
639
777
|
this._defaultFilter.next(asObservable(filter));
|
|
640
778
|
}
|
|
641
779
|
},
|
|
642
780
|
{
|
|
643
|
-
|
|
781
|
+
/**
|
|
782
|
+
* Sets an explicit filter value that takes priority over the initial and default filters.
|
|
783
|
+
*
|
|
784
|
+
* @param filter - the filter value to set
|
|
785
|
+
*/ key: "setFilter",
|
|
644
786
|
value: function setFilter(filter) {
|
|
645
787
|
this._filter.next(filter);
|
|
646
788
|
}
|
|
@@ -654,8 +796,14 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
654
796
|
}
|
|
655
797
|
},
|
|
656
798
|
{
|
|
657
|
-
|
|
658
|
-
|
|
799
|
+
/**
|
|
800
|
+
* Controls whether changes to the initial filter automatically reset the explicit filter.
|
|
801
|
+
*
|
|
802
|
+
* When enabled, any new emission from the initial filter observable clears the explicit
|
|
803
|
+
* filter, causing `filter$` to fall back to the initial filter value.
|
|
804
|
+
*
|
|
805
|
+
* @param initialFilterTakesPriority - whether initial filter changes should reset the explicit filter
|
|
806
|
+
*/ key: "setInitialFilterTakesPriority",
|
|
659
807
|
value: function setInitialFilterTakesPriority(initialFilterTakesPriority) {
|
|
660
808
|
this._initialFilterTakesPriority.next(initialFilterTakesPriority);
|
|
661
809
|
this.initFilterTakesPriority();
|
|
@@ -687,8 +835,9 @@ function _unsupported_iterable_to_array$9(o, minLen) {
|
|
|
687
835
|
}
|
|
688
836
|
},
|
|
689
837
|
{
|
|
690
|
-
|
|
691
|
-
|
|
838
|
+
/**
|
|
839
|
+
* Completes all internal subjects and cleans up subscriptions.
|
|
840
|
+
*/ key: "destroy",
|
|
692
841
|
value: function destroy() {
|
|
693
842
|
this._initialFilterSub.destroy();
|
|
694
843
|
this._initialFilterTakesPriority.complete();
|
|
@@ -759,7 +908,22 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
759
908
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
|
|
760
909
|
}
|
|
761
910
|
/**
|
|
762
|
-
*
|
|
911
|
+
* Manages a collection of reactive filters keyed by string identifiers.
|
|
912
|
+
*
|
|
913
|
+
* Multiple filter observables can be registered under the same key and their emissions are merged.
|
|
914
|
+
* Supports default filters that are used when no explicit filter is set.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```ts
|
|
918
|
+
* const filterMap = new FilterMap<{ active: boolean }>();
|
|
919
|
+
*
|
|
920
|
+
* // Register a filter observable under a key
|
|
921
|
+
* filterMap.addFilterObs('users', of({ active: true }));
|
|
922
|
+
*
|
|
923
|
+
* // Subscribe to the filter for that key
|
|
924
|
+
* filterMap.filterForKey('users').subscribe(f => console.log(f));
|
|
925
|
+
* // Output: { active: true }
|
|
926
|
+
* ```
|
|
763
927
|
*/ var FilterMap = /*#__PURE__*/ function() {
|
|
764
928
|
function FilterMap() {
|
|
765
929
|
_class_call_check$6(this, FilterMap);
|
|
@@ -767,7 +931,14 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
767
931
|
}
|
|
768
932
|
_create_class$5(FilterMap, [
|
|
769
933
|
{
|
|
770
|
-
|
|
934
|
+
/**
|
|
935
|
+
* Returns an observable of the filter value for the given key.
|
|
936
|
+
*
|
|
937
|
+
* Waits until a filter entry exists for the key, then switches to its filter stream.
|
|
938
|
+
*
|
|
939
|
+
* @param key - filter map key to observe
|
|
940
|
+
* @returns observable that emits the current filter value for the key
|
|
941
|
+
*/ key: "filterForKey",
|
|
771
942
|
value: function filterForKey(key) {
|
|
772
943
|
return this._map.pipe(map(function(x) {
|
|
773
944
|
return x.get(key);
|
|
@@ -777,25 +948,47 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
777
948
|
}
|
|
778
949
|
},
|
|
779
950
|
{
|
|
780
|
-
|
|
951
|
+
/**
|
|
952
|
+
* Sets a default filter observable for the given key, used as a fallback when no explicit filter is set.
|
|
953
|
+
*
|
|
954
|
+
* @param key - filter map key
|
|
955
|
+
* @param obs - default filter observable or value
|
|
956
|
+
*/ key: "addDefaultFilterObs",
|
|
781
957
|
value: function addDefaultFilterObs(key, obs) {
|
|
782
958
|
this._itemForKey(key).setDefaultFilterObs(obs);
|
|
783
959
|
}
|
|
784
960
|
},
|
|
785
961
|
{
|
|
786
|
-
|
|
962
|
+
/**
|
|
963
|
+
* Adds a filter observable for the given key. Multiple observables can be added per key
|
|
964
|
+
* and their emissions are merged together.
|
|
965
|
+
*
|
|
966
|
+
* @param key - filter map key
|
|
967
|
+
* @param obs - filter observable to add
|
|
968
|
+
*/ key: "addFilterObs",
|
|
787
969
|
value: function addFilterObs(key, obs) {
|
|
788
970
|
this._itemForKey(key).addFilterObs(obs);
|
|
789
971
|
}
|
|
790
972
|
},
|
|
791
973
|
{
|
|
792
|
-
|
|
974
|
+
/**
|
|
975
|
+
* Creates a {@link FilterMapKeyInstance} bound to the given key, providing both
|
|
976
|
+
* {@link FilterSource} and {@link FilterSourceConnector} interfaces for that key.
|
|
977
|
+
*
|
|
978
|
+
* @param key - filter map key to bind
|
|
979
|
+
* @returns instance for interacting with the filter at the given key
|
|
980
|
+
*/ key: "makeInstance",
|
|
793
981
|
value: function makeInstance(key) {
|
|
794
982
|
return new FilterMapKeyInstance(this, key);
|
|
795
983
|
}
|
|
796
984
|
},
|
|
797
985
|
{
|
|
798
|
-
|
|
986
|
+
/**
|
|
987
|
+
* Creates an observable that emits a new {@link FilterMapKeyInstance} each time the key changes.
|
|
988
|
+
*
|
|
989
|
+
* @param keyObs - observable of filter map keys
|
|
990
|
+
* @returns observable that emits instances for the current key
|
|
991
|
+
*/ key: "instanceObsForKeyObs",
|
|
799
992
|
value: function instanceObsForKeyObs(keyObs) {
|
|
800
993
|
var _this = this;
|
|
801
994
|
return keyObs.pipe(distinctUntilChanged(), map(function(x) {
|
|
@@ -817,8 +1010,9 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
817
1010
|
}
|
|
818
1011
|
},
|
|
819
1012
|
{
|
|
820
|
-
|
|
821
|
-
|
|
1013
|
+
/**
|
|
1014
|
+
* Destroys all filter items and completes the internal subject.
|
|
1015
|
+
*/ key: "destroy",
|
|
822
1016
|
value: function destroy() {
|
|
823
1017
|
this._map.value.forEach(function(x) {
|
|
824
1018
|
return x.destroy();
|
|
@@ -829,12 +1023,19 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
829
1023
|
]);
|
|
830
1024
|
return FilterMap;
|
|
831
1025
|
}();
|
|
832
|
-
|
|
1026
|
+
/**
|
|
1027
|
+
* Bound instance of a {@link FilterMap} for a specific key.
|
|
1028
|
+
*
|
|
1029
|
+
* Implements both {@link FilterSource} (provides filter values) and {@link FilterSourceConnector}
|
|
1030
|
+
* (accepts filter sources) for a single filter map entry.
|
|
1031
|
+
*/ var FilterMapKeyInstance = /*#__PURE__*/ function() {
|
|
833
1032
|
function FilterMapKeyInstance(dbxFilterMap, key) {
|
|
834
1033
|
_class_call_check$6(this, FilterMapKeyInstance);
|
|
835
1034
|
_define_property$a(this, "_dbxFilterMap", void 0);
|
|
836
1035
|
_define_property$a(this, "_key", void 0);
|
|
837
|
-
|
|
1036
|
+
/**
|
|
1037
|
+
* Observable of the filter value for this instance's key.
|
|
1038
|
+
*/ _define_property$a(this, "filter$", void 0);
|
|
838
1039
|
this._dbxFilterMap = dbxFilterMap;
|
|
839
1040
|
this._key = key;
|
|
840
1041
|
this.filter$ = this._dbxFilterMap.filterForKey(this._key);
|
|
@@ -853,13 +1054,17 @@ var FilterMapKeyInstance = /*#__PURE__*/ function() {
|
|
|
853
1054
|
}
|
|
854
1055
|
},
|
|
855
1056
|
{
|
|
856
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* Sets the default filter observable for this key.
|
|
1059
|
+
*/ key: "initWithFilter",
|
|
857
1060
|
value: function initWithFilter(filterObs) {
|
|
858
1061
|
this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
|
|
859
1062
|
}
|
|
860
1063
|
},
|
|
861
1064
|
{
|
|
862
|
-
|
|
1065
|
+
/**
|
|
1066
|
+
* Connects a filter source, adding its filter observable to this key's merged filters.
|
|
1067
|
+
*/ key: "connectWithSource",
|
|
863
1068
|
value: function connectWithSource(filterSource) {
|
|
864
1069
|
this.dbxFilterMap.addFilterObs(this.key, filterSource.filter$);
|
|
865
1070
|
}
|
|
@@ -960,7 +1165,31 @@ var FilterMapItem = /*#__PURE__*/ function() {
|
|
|
960
1165
|
}
|
|
961
1166
|
();
|
|
962
1167
|
|
|
963
|
-
|
|
1168
|
+
/**
|
|
1169
|
+
* Creates a mapping function that resolves preset references in filters.
|
|
1170
|
+
*
|
|
1171
|
+
* When a filter has a `preset` value, the provided function is called to expand the preset
|
|
1172
|
+
* into concrete filter values, then the `preset` field is removed from the result.
|
|
1173
|
+
* Filters without a preset are passed through unchanged.
|
|
1174
|
+
*
|
|
1175
|
+
* @param fn - function that expands a preset into concrete filter values
|
|
1176
|
+
* @returns mapping function that resolves presets and strips the preset field
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```ts
|
|
1180
|
+
* interface MyFilter extends FilterWithPreset {
|
|
1181
|
+
* active?: boolean;
|
|
1182
|
+
* }
|
|
1183
|
+
*
|
|
1184
|
+
* const resolve = makeMapFilterWithPresetFn<MyFilter>((f) => {
|
|
1185
|
+
* if (f.preset === 'active') return { active: true };
|
|
1186
|
+
* return { active: false };
|
|
1187
|
+
* });
|
|
1188
|
+
*
|
|
1189
|
+
* const result = resolve({ preset: 'active' });
|
|
1190
|
+
* // result === { active: true }
|
|
1191
|
+
* ```
|
|
1192
|
+
*/ function makeMapFilterWithPresetFn(fn) {
|
|
964
1193
|
return function(filter) {
|
|
965
1194
|
if (filter.preset) {
|
|
966
1195
|
var result = fn(filter);
|
|
@@ -971,7 +1200,12 @@ function makeMapFilterWithPresetFn(fn) {
|
|
|
971
1200
|
}
|
|
972
1201
|
};
|
|
973
1202
|
}
|
|
974
|
-
|
|
1203
|
+
/**
|
|
1204
|
+
* RxJS operator that resolves preset references in a filter stream using the provided mapping function.
|
|
1205
|
+
*
|
|
1206
|
+
* @param fn - function that expands a preset into concrete filter values
|
|
1207
|
+
* @returns operator that maps filter emissions, resolving any preset references
|
|
1208
|
+
*/ function mapFilterWithPreset(fn) {
|
|
975
1209
|
return map(makeMapFilterWithPresetFn(fn));
|
|
976
1210
|
}
|
|
977
1211
|
|
|
@@ -1035,12 +1269,17 @@ function _is_native_reflect_construct$1() {
|
|
|
1035
1269
|
})();
|
|
1036
1270
|
}
|
|
1037
1271
|
/**
|
|
1038
|
-
*
|
|
1272
|
+
* Abstract base class for providing reactive filter state.
|
|
1273
|
+
*
|
|
1274
|
+
* Implementations expose a `filter$` observable that emits the current filter value,
|
|
1275
|
+
* and optionally support initialization from an external observable.
|
|
1039
1276
|
*/ var FilterSource = function FilterSource() {
|
|
1040
1277
|
_class_call_check$5(this, FilterSource);
|
|
1041
1278
|
};
|
|
1042
1279
|
/**
|
|
1043
|
-
* A FilterSource
|
|
1280
|
+
* A {@link FilterSource} whose filter type includes an optional preset reference.
|
|
1281
|
+
*
|
|
1282
|
+
* Useful for filter UIs that support both preset configurations and custom filter values.
|
|
1044
1283
|
*/ var PresetFilterSource = /*#__PURE__*/ function(FilterSource) {
|
|
1045
1284
|
_inherits$1(PresetFilterSource, FilterSource);
|
|
1046
1285
|
function PresetFilterSource() {
|
|
@@ -1050,7 +1289,9 @@ function _is_native_reflect_construct$1() {
|
|
|
1050
1289
|
return PresetFilterSource;
|
|
1051
1290
|
}(FilterSource);
|
|
1052
1291
|
/**
|
|
1053
|
-
*
|
|
1292
|
+
* Abstract connector that wires a {@link FilterSource} into a consuming component.
|
|
1293
|
+
*
|
|
1294
|
+
* Implementations define how to subscribe to a filter source and apply its values.
|
|
1054
1295
|
*/ var FilterSourceConnector = function FilterSourceConnector() {
|
|
1055
1296
|
_class_call_check$5(this, FilterSourceConnector);
|
|
1056
1297
|
}
|
|
@@ -1185,10 +1426,11 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1185
1426
|
}
|
|
1186
1427
|
}
|
|
1187
1428
|
/**
|
|
1188
|
-
*
|
|
1429
|
+
* Combines an iteration's `hasNext$` and `canLoadMore$` into a single observable that emits
|
|
1430
|
+
* `true` only when both conditions are met (more items exist and the page limit hasn't been reached).
|
|
1189
1431
|
*
|
|
1190
|
-
* @param iteration
|
|
1191
|
-
* @returns
|
|
1432
|
+
* @param iteration - the iteration to check
|
|
1433
|
+
* @returns observable that emits `true` when more items can be loaded
|
|
1192
1434
|
*/ function iterationHasNextAndCanLoadMore(iteration) {
|
|
1193
1435
|
return iteration.canLoadMore$.pipe(switchMap(function(canLoadMore) {
|
|
1194
1436
|
if (canLoadMore) {
|
|
@@ -1199,15 +1441,16 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1199
1441
|
}), shareReplay(1));
|
|
1200
1442
|
}
|
|
1201
1443
|
/**
|
|
1202
|
-
* Automatically
|
|
1444
|
+
* Automatically pages through a {@link PageItemIteration} until its configured max page load limit is reached.
|
|
1203
1445
|
*
|
|
1204
|
-
*
|
|
1446
|
+
* Falls back to the provided default limit if no max is configured on the iterator.
|
|
1205
1447
|
*
|
|
1206
|
-
*
|
|
1448
|
+
* @param iterator - the page iteration to advance
|
|
1449
|
+
* @param defaultLimit - fallback page limit if none is configured (defaults to 100)
|
|
1450
|
+
* @returns promise resolving to the last loaded page number
|
|
1207
1451
|
*
|
|
1208
|
-
* @
|
|
1209
|
-
* @
|
|
1210
|
-
* @returns
|
|
1452
|
+
* @throws {Error} If neither a max page load limit nor a default limit is defined
|
|
1453
|
+
* @throws Rejects if the iteration encounters a loading error
|
|
1211
1454
|
*/ function iteratorNextPageUntilMaxPageLoadLimit(iterator) {
|
|
1212
1455
|
var defaultLimit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 100;
|
|
1213
1456
|
return iteratorNextPageUntilPage(iterator, function() {
|
|
@@ -1220,13 +1463,14 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1220
1463
|
});
|
|
1221
1464
|
}
|
|
1222
1465
|
/**
|
|
1223
|
-
* Automatically
|
|
1466
|
+
* Automatically pages through a {@link PageItemIteration} until the specified page number is reached,
|
|
1467
|
+
* respecting the iteration's max page load limit.
|
|
1224
1468
|
*
|
|
1225
|
-
*
|
|
1469
|
+
* @param iteration - the page iteration to advance
|
|
1470
|
+
* @param page - target page number (or getter returning one) representing total pages to load
|
|
1471
|
+
* @returns promise resolving to the last loaded page number
|
|
1226
1472
|
*
|
|
1227
|
-
* @
|
|
1228
|
-
* @param page
|
|
1229
|
-
* @returns
|
|
1473
|
+
* @throws Rejects if the iteration encounters a loading error
|
|
1230
1474
|
*/ function iteratorNextPageUntilPage(iteration, page) {
|
|
1231
1475
|
var getPageLimit = asGetter(page);
|
|
1232
1476
|
function checkPageLimit(page) {
|
|
@@ -1330,15 +1574,14 @@ function scanIntoArray() {
|
|
|
1330
1574
|
}, []);
|
|
1331
1575
|
}
|
|
1332
1576
|
/**
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
* The piped observable is for retrieving the seed value, and the accumulatorObs observable is used for
|
|
1336
|
-
* retrieving values going forward.
|
|
1577
|
+
* Lazily builds an array from a seed observable and an accumulator observable.
|
|
1337
1578
|
*
|
|
1338
|
-
*
|
|
1579
|
+
* The piped observable provides the seed state, while `accumulatorObs` provides values that
|
|
1580
|
+
* are incrementally appended. Useful when loading large datasets where the initial page and
|
|
1581
|
+
* subsequent pages come from different sources.
|
|
1339
1582
|
*
|
|
1340
|
-
* @param
|
|
1341
|
-
* @returns
|
|
1583
|
+
* @param init - function that receives the seed state and returns the accumulator config
|
|
1584
|
+
* @returns an operator that emits the growing array
|
|
1342
1585
|
*/ function scanBuildArray(init) {
|
|
1343
1586
|
return exhaustMap(function(seedState) {
|
|
1344
1587
|
var _init = init(seedState), _init_seed = _init.seed, seed = _init_seed === void 0 ? [] : _init_seed, accumulatorObs = _init.accumulatorObs, _init_flattenArray = _init.flattenArray, flattenArray = _init_flattenArray === void 0 ? false : _init_flattenArray;
|
|
@@ -1358,10 +1601,10 @@ function scanIntoArray() {
|
|
|
1358
1601
|
}
|
|
1359
1602
|
// MARK: MapForEach
|
|
1360
1603
|
/**
|
|
1361
|
-
*
|
|
1604
|
+
* RxJS operator that executes a side-effect on each element of the emitted array, then passes the array through.
|
|
1362
1605
|
*
|
|
1363
|
-
* @param forEach
|
|
1364
|
-
* @returns
|
|
1606
|
+
* @param forEach - callback to run for each element, or null/undefined to pass through unchanged
|
|
1607
|
+
* @returns an operator that taps each element in emitted arrays
|
|
1365
1608
|
*/ function mapForEach(forEach) {
|
|
1366
1609
|
return forEach ? map(function(x) {
|
|
1367
1610
|
return forEachWithArray(x, forEach);
|
|
@@ -1370,7 +1613,14 @@ function scanIntoArray() {
|
|
|
1370
1613
|
});
|
|
1371
1614
|
}
|
|
1372
1615
|
/**
|
|
1373
|
-
*
|
|
1616
|
+
* RxJS operator that maps each element in an emitted array through an async observable function,
|
|
1617
|
+
* then combines all results using `combineLatest`.
|
|
1618
|
+
*
|
|
1619
|
+
* Emits `[]` for empty arrays. When `onlyFirst` is true, takes only the first combined emission.
|
|
1620
|
+
*
|
|
1621
|
+
* @param mapFunction - function that maps each item to an ObservableInput
|
|
1622
|
+
* @param config - optional config (e.g., `onlyFirst`)
|
|
1623
|
+
* @returns an operator that async-maps each array element
|
|
1374
1624
|
*/ function mapEachAsync(mapFunction, config) {
|
|
1375
1625
|
var _ref = config !== null && config !== void 0 ? config : {}, _ref_onlyFirst = _ref.onlyFirst, onlyFirst = _ref_onlyFirst === void 0 ? false : _ref_onlyFirst;
|
|
1376
1626
|
return switchMap(function(values) {
|
|
@@ -1388,9 +1638,21 @@ function scanIntoArray() {
|
|
|
1388
1638
|
}
|
|
1389
1639
|
|
|
1390
1640
|
/**
|
|
1391
|
-
*
|
|
1641
|
+
* RxJS operator that emits only when the stream transitions from a `from` value to a `to` value.
|
|
1392
1642
|
*
|
|
1393
|
-
* The
|
|
1643
|
+
* The `from` value must be seen first; only then is the `to` value emitted. When `requireConsecutive`
|
|
1644
|
+
* is true, the two values must be adjacent emissions.
|
|
1645
|
+
*
|
|
1646
|
+
* @example
|
|
1647
|
+
* ```ts
|
|
1648
|
+
* // Emit when transitioning from true to false
|
|
1649
|
+
* source$.pipe(
|
|
1650
|
+
* onMatchDelta({ from: true, to: false, requireConsecutive: true })
|
|
1651
|
+
* ).subscribe((val) => console.log('Transitioned to false'));
|
|
1652
|
+
* ```
|
|
1653
|
+
*
|
|
1654
|
+
* @param config - from/to values, optional comparator, and consecutive requirement
|
|
1655
|
+
* @returns an operator that emits on value transitions
|
|
1394
1656
|
*/ function onMatchDelta(config) {
|
|
1395
1657
|
var inputIsSame = config.isMatch, from = config.from, to = config.to, requireConsecutive = config.requireConsecutive;
|
|
1396
1658
|
var isMatch = inputIsSame !== null && inputIsSame !== void 0 ? inputIsSame : function(a, b) {
|
|
@@ -1447,19 +1709,23 @@ function scanIntoArray() {
|
|
|
1447
1709
|
}
|
|
1448
1710
|
|
|
1449
1711
|
/**
|
|
1450
|
-
* Returns the pipe
|
|
1712
|
+
* Conditionally applies an operator. Returns the given pipe when `usePipe` is true, otherwise returns identity (pass-through).
|
|
1713
|
+
*
|
|
1714
|
+
* @param usePipe - whether to apply the pipe
|
|
1715
|
+
* @param pipe - the operator to conditionally apply
|
|
1716
|
+
* @returns the pipe or identity operator
|
|
1451
1717
|
*/ function pipeIf(usePipe, pipe) {
|
|
1452
1718
|
return usePipe ? pipe : identity;
|
|
1453
1719
|
}
|
|
1454
1720
|
/**
|
|
1455
|
-
*
|
|
1721
|
+
* RxJS operator that negates each emitted boolean value.
|
|
1456
1722
|
*/ function isNot() {
|
|
1457
1723
|
return map(function(x) {
|
|
1458
1724
|
return !x;
|
|
1459
1725
|
});
|
|
1460
1726
|
}
|
|
1461
1727
|
/**
|
|
1462
|
-
*
|
|
1728
|
+
* RxJS operator that only emits when a boolean stream transitions from `true` to `false`.
|
|
1463
1729
|
*/ function onTrueToFalse() {
|
|
1464
1730
|
return onMatchDelta({
|
|
1465
1731
|
from: true,
|
|
@@ -1468,7 +1734,7 @@ function scanIntoArray() {
|
|
|
1468
1734
|
});
|
|
1469
1735
|
}
|
|
1470
1736
|
/**
|
|
1471
|
-
*
|
|
1737
|
+
* RxJS operator that only emits when a boolean stream transitions from `false` to `true`.
|
|
1472
1738
|
*/ function onFalseToTrue() {
|
|
1473
1739
|
return onMatchDelta({
|
|
1474
1740
|
from: false,
|
|
@@ -1478,11 +1744,13 @@ function scanIntoArray() {
|
|
|
1478
1744
|
}
|
|
1479
1745
|
|
|
1480
1746
|
/**
|
|
1481
|
-
*
|
|
1747
|
+
* Wraps an {@link ObservableDecisionFunction} to negate its boolean result.
|
|
1482
1748
|
*
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
* @
|
|
1749
|
+
* When `invert` is false, returns the original function unchanged.
|
|
1750
|
+
*
|
|
1751
|
+
* @param decisionFn - the decision function to invert
|
|
1752
|
+
* @param invert - whether to apply the inversion (defaults to true)
|
|
1753
|
+
* @returns the inverted (or original) decision function
|
|
1486
1754
|
*/ function invertObservableDecision(decisionFn) {
|
|
1487
1755
|
var invert = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
1488
1756
|
if (invert) {
|
|
@@ -1497,10 +1765,14 @@ function scanIntoArray() {
|
|
|
1497
1765
|
}
|
|
1498
1766
|
}
|
|
1499
1767
|
/**
|
|
1500
|
-
*
|
|
1768
|
+
* RxJS operator that filters an emitted array by evaluating each item through an async {@link ObservableDecisionFunction}.
|
|
1501
1769
|
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1770
|
+
* Items where the decision returns true are kept; others are removed. Results are throttled
|
|
1771
|
+
* to prevent excessive re-emissions.
|
|
1772
|
+
*
|
|
1773
|
+
* @param observableDecisionFunction - async predicate to evaluate each item
|
|
1774
|
+
* @param throttle - throttle duration in ms (defaults to 20)
|
|
1775
|
+
* @returns an operator that async-filters array elements
|
|
1504
1776
|
*/ function filterItemsWithObservableDecision(observableDecisionFunction) {
|
|
1505
1777
|
var throttle = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 20;
|
|
1506
1778
|
var filterAndMap = filterAndMapFunction(function(x) {
|
|
@@ -1531,10 +1803,11 @@ function scanIntoArray() {
|
|
|
1531
1803
|
}
|
|
1532
1804
|
|
|
1533
1805
|
/**
|
|
1534
|
-
*
|
|
1806
|
+
* RxJS operator that maps each emission to a new {@link Expires} object with an expiration
|
|
1807
|
+
* time relative to the current moment.
|
|
1535
1808
|
*
|
|
1536
|
-
* @param expiresIn
|
|
1537
|
-
* @returns
|
|
1809
|
+
* @param expiresIn - duration in milliseconds until expiration
|
|
1810
|
+
* @returns an operator that maps values to Expires objects
|
|
1538
1811
|
*/ function toExpiration(expiresIn) {
|
|
1539
1812
|
return map(function() {
|
|
1540
1813
|
var now = new Date();
|
|
@@ -1548,7 +1821,7 @@ function scanIntoArray() {
|
|
|
1548
1821
|
});
|
|
1549
1822
|
}
|
|
1550
1823
|
/**
|
|
1551
|
-
*
|
|
1824
|
+
* RxJS operator that filters out emissions whose {@link Expires} value has already expired.
|
|
1552
1825
|
*/ function skipExpired() {
|
|
1553
1826
|
return filter(function(expires) {
|
|
1554
1827
|
return !expirationDetails({
|
|
@@ -1557,7 +1830,9 @@ function scanIntoArray() {
|
|
|
1557
1830
|
});
|
|
1558
1831
|
}
|
|
1559
1832
|
/**
|
|
1560
|
-
*
|
|
1833
|
+
* RxJS operator that skips emissions until the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1834
|
+
*
|
|
1835
|
+
* @param expiresIn - duration in milliseconds
|
|
1561
1836
|
*/ function skipUntilExpiration(expiresIn) {
|
|
1562
1837
|
return filter(function(x) {
|
|
1563
1838
|
return expirationDetails({
|
|
@@ -1567,7 +1842,9 @@ function scanIntoArray() {
|
|
|
1567
1842
|
});
|
|
1568
1843
|
}
|
|
1569
1844
|
/**
|
|
1570
|
-
*
|
|
1845
|
+
* RxJS operator that skips emissions after the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
1846
|
+
*
|
|
1847
|
+
* @param expiresIn - duration in milliseconds
|
|
1571
1848
|
*/ function skipAfterExpiration(expiresIn) {
|
|
1572
1849
|
return filter(function(x) {
|
|
1573
1850
|
return !expirationDetails({
|
|
@@ -1577,7 +1854,10 @@ function scanIntoArray() {
|
|
|
1577
1854
|
});
|
|
1578
1855
|
}
|
|
1579
1856
|
/**
|
|
1580
|
-
*
|
|
1857
|
+
* RxJS operator that only takes emissions from the source within a time window after each emission from a watch observable.
|
|
1858
|
+
*
|
|
1859
|
+
* @param watch - observable whose emissions reset the time window
|
|
1860
|
+
* @param takeFor - duration in milliseconds of each time window
|
|
1581
1861
|
*/ function skipUntilTimeElapsedAfterLastEmission(watch, takeFor) {
|
|
1582
1862
|
return function(observable) {
|
|
1583
1863
|
return watch.pipe(switchMap(function() {
|
|
@@ -1592,7 +1872,11 @@ function scanIntoArray() {
|
|
|
1592
1872
|
};
|
|
1593
1873
|
}
|
|
1594
1874
|
/**
|
|
1595
|
-
*
|
|
1875
|
+
* RxJS operator that skips emissions from the source for a duration after each emission from a watch observable,
|
|
1876
|
+
* then passes values through once the time has elapsed.
|
|
1877
|
+
*
|
|
1878
|
+
* @param watch - observable whose emissions reset the skip window
|
|
1879
|
+
* @param skipFor - duration in milliseconds to skip after each watch emission
|
|
1596
1880
|
*/ function takeAfterTimeElapsedSinceLastEmission(watch, skipFor) {
|
|
1597
1881
|
return function(observable) {
|
|
1598
1882
|
return watch.pipe(switchMap(function() {
|
|
@@ -1608,7 +1892,13 @@ function scanIntoArray() {
|
|
|
1608
1892
|
}
|
|
1609
1893
|
|
|
1610
1894
|
/**
|
|
1611
|
-
*
|
|
1895
|
+
* RxJS operator that emits a default value if the source does not emit within the specified timeout.
|
|
1896
|
+
*
|
|
1897
|
+
* After the timeout, the default value is prepended and the source continues normally.
|
|
1898
|
+
*
|
|
1899
|
+
* @param defaultValue - value or getter to use as the default
|
|
1900
|
+
* @param first - timeout in ms before emitting the default (defaults to 0)
|
|
1901
|
+
* @returns an operator that provides a fallback on slow emissions
|
|
1612
1902
|
*/ function timeoutStartWith(defaultValue) {
|
|
1613
1903
|
var first = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
1614
1904
|
return function(source) {
|
|
@@ -1620,7 +1910,13 @@ function scanIntoArray() {
|
|
|
1620
1910
|
}));
|
|
1621
1911
|
};
|
|
1622
1912
|
}
|
|
1623
|
-
|
|
1913
|
+
/**
|
|
1914
|
+
* RxJS operator that executes a side-effect function if the source does not emit within the given timeout.
|
|
1915
|
+
*
|
|
1916
|
+
* @param timeoutDelay - timeout in ms before triggering the side-effect
|
|
1917
|
+
* @param useFn - side-effect function to call on timeout
|
|
1918
|
+
* @returns an operator that taps after timeout
|
|
1919
|
+
*/ function tapAfterTimeout(timeoutDelay, useFn) {
|
|
1624
1920
|
return timeout({
|
|
1625
1921
|
first: timeoutDelay,
|
|
1626
1922
|
with: function _with() {
|
|
@@ -1628,7 +1924,13 @@ function tapAfterTimeout(timeoutDelay, useFn) {
|
|
|
1628
1924
|
}
|
|
1629
1925
|
});
|
|
1630
1926
|
}
|
|
1631
|
-
|
|
1927
|
+
/**
|
|
1928
|
+
* RxJS operator that throws an error if the source does not emit within the given timeout.
|
|
1929
|
+
*
|
|
1930
|
+
* @param timeoutDelay - timeout in ms before throwing
|
|
1931
|
+
* @param error - getter that produces the error to throw
|
|
1932
|
+
* @returns an operator that throws on timeout
|
|
1933
|
+
*/ function throwErrorAfterTimeout(timeoutDelay, error) {
|
|
1632
1934
|
return timeout({
|
|
1633
1935
|
first: timeoutDelay,
|
|
1634
1936
|
with: function _with() {
|
|
@@ -1641,10 +1943,23 @@ function throwErrorAfterTimeout(timeoutDelay, error) {
|
|
|
1641
1943
|
|
|
1642
1944
|
var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
1643
1945
|
/**
|
|
1644
|
-
* Creates an observable that
|
|
1946
|
+
* Creates an observable that emits values produced by a factory function on a timer interval.
|
|
1645
1947
|
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1948
|
+
* Wraps `timer()` internally and maps each tick index through the factory. Optionally limits
|
|
1949
|
+
* the total number of emissions.
|
|
1950
|
+
*
|
|
1951
|
+
* @example
|
|
1952
|
+
* ```ts
|
|
1953
|
+
* const countdown$ = factoryTimer({
|
|
1954
|
+
* factory: (i) => 10 - i,
|
|
1955
|
+
* interval: 1000,
|
|
1956
|
+
* limit: 11
|
|
1957
|
+
* });
|
|
1958
|
+
* // emits 10, 9, 8, ... 0
|
|
1959
|
+
* ```
|
|
1960
|
+
*
|
|
1961
|
+
* @param config - timer configuration including factory, interval, wait, and limit
|
|
1962
|
+
* @returns an observable of factory-produced values
|
|
1648
1963
|
*/ function factoryTimer(config) {
|
|
1649
1964
|
var _config_wait = config.wait, wait = _config_wait === void 0 ? 0 : _config_wait, _config_interval = config.interval, interval = _config_interval === void 0 ? DEFAULT_FACTORY_TIMER_INTERVAL : _config_interval, limit = config.limit, factory = config.factory;
|
|
1650
1965
|
var obs = timer(wait, interval);
|
|
@@ -1659,29 +1974,33 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
|
1659
1974
|
}
|
|
1660
1975
|
|
|
1661
1976
|
/**
|
|
1662
|
-
* distinctUntilChanged
|
|
1977
|
+
* `distinctUntilChanged` variant for arrays that only emits when the set of keys extracted from
|
|
1978
|
+
* the array elements changes.
|
|
1663
1979
|
*
|
|
1664
|
-
* @param
|
|
1980
|
+
* @param readKey - function to extract one or more keys from each element
|
|
1981
|
+
* @returns an operator that filters out arrays with unchanged key sets
|
|
1665
1982
|
*/ function distinctUntilKeysChange(readKey) {
|
|
1666
1983
|
return distinctUntilChanged(objectKeysEqualityComparatorFunction(readKey));
|
|
1667
1984
|
}
|
|
1668
1985
|
/**
|
|
1669
|
-
*
|
|
1986
|
+
* `distinctUntilChanged` variant for single objects that only emits when the extracted key changes.
|
|
1670
1987
|
*
|
|
1671
|
-
* @param readKey
|
|
1672
|
-
* @returns
|
|
1988
|
+
* @param readKey - function to extract a key from the emitted object
|
|
1989
|
+
* @returns an operator that filters out emissions with unchanged keys
|
|
1673
1990
|
*/ function distinctUntilObjectKeyChange(readKey) {
|
|
1674
1991
|
return distinctUntilChanged(objectKeyEqualityComparatorFunction(readKey));
|
|
1675
1992
|
}
|
|
1676
1993
|
|
|
1677
1994
|
/**
|
|
1678
|
-
*
|
|
1995
|
+
* RxJS operator that calls a destroy function on the previous value whenever a new value is emitted.
|
|
1679
1996
|
*
|
|
1680
|
-
*
|
|
1997
|
+
* Ensures proper cleanup of resources when switching between instances. When `wait` is true,
|
|
1998
|
+
* delays emitting the new value until the previous destruction completes.
|
|
1999
|
+
* On unsubscription, the last emitted instance is also destroyed.
|
|
1681
2000
|
*
|
|
1682
|
-
* @param destroy
|
|
1683
|
-
* @param wait
|
|
1684
|
-
* @returns
|
|
2001
|
+
* @param destroy - function to clean up each replaced instance
|
|
2002
|
+
* @param wait - whether to wait for the previous destroy to complete before emitting
|
|
2003
|
+
* @returns an operator that manages instance lifecycle
|
|
1685
2004
|
*/ function cleanup(destroy) {
|
|
1686
2005
|
var wait = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1687
2006
|
return function(obs) {
|
|
@@ -1715,9 +2034,10 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
|
1715
2034
|
};
|
|
1716
2035
|
}
|
|
1717
2036
|
/**
|
|
1718
|
-
* Convenience
|
|
2037
|
+
* Convenience wrapper for {@link cleanup} that calls `destroy()` on each replaced {@link Destroyable} instance.
|
|
1719
2038
|
*
|
|
1720
|
-
* @
|
|
2039
|
+
* @param wait - whether to wait for the previous destroy to complete before emitting
|
|
2040
|
+
* @returns an operator that manages Destroyable lifecycle
|
|
1721
2041
|
*/ function cleanupDestroyable(wait) {
|
|
1722
2042
|
return cleanup(function(x) {
|
|
1723
2043
|
return x.destroy();
|
|
@@ -1725,9 +2045,17 @@ var DEFAULT_FACTORY_TIMER_INTERVAL = 1000;
|
|
|
1725
2045
|
}
|
|
1726
2046
|
|
|
1727
2047
|
/**
|
|
1728
|
-
*
|
|
2048
|
+
* RxJS operator that emits `true` immediately (loading), then `false` after the source emits its first value.
|
|
1729
2049
|
*
|
|
1730
|
-
*
|
|
2050
|
+
* Only considers the first emission from the source. The result is shared via `shareReplay(1)`.
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* ```ts
|
|
2054
|
+
* const loading$ = dataFetch$.pipe(isLoading());
|
|
2055
|
+
* // emits true initially, then false once dataFetch$ emits
|
|
2056
|
+
* ```
|
|
2057
|
+
*
|
|
2058
|
+
* @returns an operator that tracks whether the first value has been emitted
|
|
1731
2059
|
*/ function isLoading() {
|
|
1732
2060
|
return function(source) {
|
|
1733
2061
|
return source.pipe(first(), map(function() {
|
|
@@ -1751,15 +2079,23 @@ function tapLog(messageOrFunction) {
|
|
|
1751
2079
|
return operator;
|
|
1752
2080
|
}
|
|
1753
2081
|
/**
|
|
1754
|
-
*
|
|
2082
|
+
* RxJS operator that adds a random delay before each emission.
|
|
1755
2083
|
*
|
|
1756
|
-
*
|
|
1757
|
-
*
|
|
2084
|
+
* Useful for simulating network latency or staggering requests.
|
|
2085
|
+
*
|
|
2086
|
+
* @param maxOrArgs - maximum delay in ms, or a full random number config
|
|
2087
|
+
* @returns an operator that delays each emission by a random amount
|
|
1758
2088
|
*/ function randomDelay(maxOrArgs) {
|
|
1759
2089
|
var makeRandomDelay = randomNumberFactory(maxOrArgs);
|
|
1760
2090
|
return randomDelayWithRandomFunction(makeRandomDelay);
|
|
1761
2091
|
}
|
|
1762
|
-
|
|
2092
|
+
/**
|
|
2093
|
+
* RxJS operator that adds a random delay using a custom random number generator.
|
|
2094
|
+
*
|
|
2095
|
+
* @param makeRandomDelay - factory that produces random delay values
|
|
2096
|
+
* @param scheduler - the scheduler to use for the delay (defaults to asyncScheduler)
|
|
2097
|
+
* @returns an operator that delays each emission
|
|
2098
|
+
*/ function randomDelayWithRandomFunction(makeRandomDelay) {
|
|
1763
2099
|
var scheduler = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : asyncScheduler;
|
|
1764
2100
|
return delayWhen(function() {
|
|
1765
2101
|
return timer(makeRandomDelay(), scheduler);
|
|
@@ -1767,14 +2103,14 @@ function randomDelayWithRandomFunction(makeRandomDelay) {
|
|
|
1767
2103
|
}
|
|
1768
2104
|
|
|
1769
2105
|
/**
|
|
1770
|
-
* distinctUntilChanged
|
|
2106
|
+
* `distinctUntilChanged` variant that only emits when the model's `id` property changes.
|
|
1771
2107
|
*/ function distinctUntilModelIdChange() {
|
|
1772
2108
|
return distinctUntilObjectKeyChange(function(x) {
|
|
1773
2109
|
return x.id;
|
|
1774
2110
|
});
|
|
1775
2111
|
}
|
|
1776
2112
|
/**
|
|
1777
|
-
* distinctUntilChanged
|
|
2113
|
+
* `distinctUntilChanged` variant that only emits when the model's `key` property changes.
|
|
1778
2114
|
*/ function distinctUntilModelKeyChange() {
|
|
1779
2115
|
return distinctUntilObjectKeyChange(function(x) {
|
|
1780
2116
|
return x.key;
|
|
@@ -1782,10 +2118,11 @@ function randomDelayWithRandomFunction(makeRandomDelay) {
|
|
|
1782
2118
|
}
|
|
1783
2119
|
|
|
1784
2120
|
/**
|
|
1785
|
-
*
|
|
2121
|
+
* RxJS operator that extracts values from a keyed object using a keys observable,
|
|
2122
|
+
* returning only the values whose keys are present in both.
|
|
1786
2123
|
*
|
|
1787
|
-
* @param keysObs
|
|
1788
|
-
* @returns
|
|
2124
|
+
* @param keysObs - observable (or static value) of keys to intersect with
|
|
2125
|
+
* @returns an operator that maps a keyed object to an array of matching values
|
|
1789
2126
|
*/ function mapKeysIntersectionToArray(keysObs) {
|
|
1790
2127
|
return switchMap(function(object) {
|
|
1791
2128
|
return asObservable(keysObs).pipe(map(function(keys) {
|
|
@@ -1794,9 +2131,9 @@ function randomDelayWithRandomFunction(makeRandomDelay) {
|
|
|
1794
2131
|
});
|
|
1795
2132
|
}
|
|
1796
2133
|
/**
|
|
1797
|
-
*
|
|
2134
|
+
* `distinctUntilChanged` variant for `Map` instances that only emits when the set of map keys changes.
|
|
1798
2135
|
*
|
|
1799
|
-
* @returns
|
|
2136
|
+
* @returns an operator that filters out Maps with unchanged key sets
|
|
1800
2137
|
*/ function distinctUntilMapHasDifferentKeys() {
|
|
1801
2138
|
return distinctUntilChanged(mapsHaveSameKeys);
|
|
1802
2139
|
}
|
|
@@ -1849,7 +2186,11 @@ function _object_spread_props$7(target, source) {
|
|
|
1849
2186
|
return target;
|
|
1850
2187
|
}
|
|
1851
2188
|
/**
|
|
1852
|
-
*
|
|
2189
|
+
* RxJS operator that counts emissions as they occur using `scan`, emitting the running count
|
|
2190
|
+
* after each emission (unlike `count()` which only emits on completion).
|
|
2191
|
+
*
|
|
2192
|
+
* @param startAt - initial count value (defaults to 0)
|
|
2193
|
+
* @returns an operator that emits the running emission count
|
|
1853
2194
|
*/ function scanCount() {
|
|
1854
2195
|
var startAt = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
1855
2196
|
return scan(function(count) {
|
|
@@ -1857,10 +2198,10 @@ function _object_spread_props$7(target, source) {
|
|
|
1857
2198
|
}, startAt);
|
|
1858
2199
|
}
|
|
1859
2200
|
/**
|
|
1860
|
-
* Creates a factoryTimer
|
|
2201
|
+
* Creates a {@link factoryTimer} that emits incrementing numbers on an interval.
|
|
1861
2202
|
*
|
|
1862
|
-
* @param config
|
|
1863
|
-
* @returns
|
|
2203
|
+
* @param config - timer and incrementing number configuration
|
|
2204
|
+
* @returns an observable of incrementing numbers
|
|
1864
2205
|
*/ function incrementingNumberTimer() {
|
|
1865
2206
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1866
2207
|
return factoryTimer(_object_spread_props$7(_object_spread$7({}, config), {
|
|
@@ -1915,12 +2256,14 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1915
2256
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
|
|
1916
2257
|
}
|
|
1917
2258
|
/**
|
|
1918
|
-
*
|
|
2259
|
+
* Combines `startWith` and {@link tapFirst} to initialize an observable pipe with a side-effect on the first emission.
|
|
1919
2260
|
*
|
|
1920
|
-
*
|
|
1921
|
-
*
|
|
1922
|
-
* @param
|
|
1923
|
-
* @
|
|
2261
|
+
* Emits the `initial` value first, then taps on the first emitted value to run the provided callback.
|
|
2262
|
+
*
|
|
2263
|
+
* @param tap - side-effect function called with the first value
|
|
2264
|
+
* @param initial - optional starting value emitted before the source
|
|
2265
|
+
* @param skipFirst - if true, skips tapping the initial value
|
|
2266
|
+
* @returns an operator that initializes the pipe with a tap
|
|
1924
2267
|
*/ function initialize(tap, initial, skipFirst) {
|
|
1925
2268
|
return function(source) {
|
|
1926
2269
|
var subscriber = source.pipe(startWith(initial), tapFirst(function(x) {
|
|
@@ -1930,11 +2273,11 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1930
2273
|
};
|
|
1931
2274
|
}
|
|
1932
2275
|
/**
|
|
1933
|
-
*
|
|
2276
|
+
* Executes a side-effect on the first emission from the observable, then passes all values through.
|
|
1934
2277
|
*
|
|
1935
|
-
* @param tap
|
|
1936
|
-
* @param skipFirst
|
|
1937
|
-
* @returns
|
|
2278
|
+
* @param tap - the side-effect function to call once
|
|
2279
|
+
* @param skipFirst - if true, skips the very first emission before tapping
|
|
2280
|
+
* @returns an operator that taps the first value
|
|
1938
2281
|
*/ function tapFirst(tap) {
|
|
1939
2282
|
var skipFirst = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1940
2283
|
return skipWhile(function(value) {
|
|
@@ -1944,13 +2287,13 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1944
2287
|
});
|
|
1945
2288
|
}
|
|
1946
2289
|
/**
|
|
1947
|
-
*
|
|
2290
|
+
* Wraps an observable so that it never emits `complete` until it is unsubscribed.
|
|
1948
2291
|
*
|
|
1949
|
-
* The subscription will never have complete() called
|
|
1950
|
-
*
|
|
2292
|
+
* The subscription will never have `complete()` called since it only triggers after unsubscription.
|
|
2293
|
+
* Use `finalize()` for additional cleanup.
|
|
1951
2294
|
*
|
|
1952
|
-
* @param obs
|
|
1953
|
-
* @returns
|
|
2295
|
+
* @param obs - the source observable to wrap
|
|
2296
|
+
* @returns an observable that only completes on unsubscription
|
|
1954
2297
|
*/ function preventComplete(obs) {
|
|
1955
2298
|
var complete = new BehaviorSubject(0);
|
|
1956
2299
|
return combineLatest([
|
|
@@ -1964,12 +2307,18 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1964
2307
|
}));
|
|
1965
2308
|
}
|
|
1966
2309
|
/**
|
|
1967
|
-
*
|
|
2310
|
+
* Creates a cold observable that defers execution of the getter until subscription, then shares the result.
|
|
1968
2311
|
*
|
|
1969
|
-
*
|
|
2312
|
+
* Unlike `from()`, the promise/observable is not created until the first subscriber connects.
|
|
1970
2313
|
*
|
|
1971
|
-
* @
|
|
1972
|
-
*
|
|
2314
|
+
* @example
|
|
2315
|
+
* ```ts
|
|
2316
|
+
* const data$ = lazyFrom(() => fetch('/api/data').then(r => r.json()));
|
|
2317
|
+
* // The fetch is not called until data$ is subscribed to
|
|
2318
|
+
* ```
|
|
2319
|
+
*
|
|
2320
|
+
* @param getter - factory that returns a Promise or Observable
|
|
2321
|
+
* @returns a shared observable that defers execution until subscription
|
|
1973
2322
|
*/ function lazyFrom(getter) {
|
|
1974
2323
|
return of(undefined).pipe(mergeMap(function() {
|
|
1975
2324
|
return from(getter());
|
|
@@ -1977,10 +2326,13 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1977
2326
|
}
|
|
1978
2327
|
|
|
1979
2328
|
/**
|
|
1980
|
-
*
|
|
2329
|
+
* RxJS operator that filters an array to unique items based on a key reader function.
|
|
1981
2330
|
*
|
|
1982
|
-
* @
|
|
1983
|
-
*
|
|
2331
|
+
* Uses {@link filterUniqueFunction} to deduplicate emitted arrays by extracting a key from each item.
|
|
2332
|
+
*
|
|
2333
|
+
* @param readKey - function to extract the unique key from each item
|
|
2334
|
+
* @param additionalKeysInput - optional additional keys to include in the unique set
|
|
2335
|
+
* @returns an operator that emits deduplicated arrays
|
|
1984
2336
|
*/ function filterUnique(readKey, additionalKeysInput) {
|
|
1985
2337
|
var filterFn = filterUniqueFunction(readKey, additionalKeysInput);
|
|
1986
2338
|
return map(function(x) {
|
|
@@ -1992,10 +2344,23 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1992
2344
|
* Default amount of throttle in milliseconds used by AsyncPusher.
|
|
1993
2345
|
*/ var DEFAULT_ASYNC_PUSHER_THROTTLE = 200;
|
|
1994
2346
|
/**
|
|
1995
|
-
* Creates an AsyncPusher.
|
|
2347
|
+
* Creates an {@link AsyncPusher} — a callable function backed by a throttled {@link BehaviorSubject}.
|
|
1996
2348
|
*
|
|
1997
|
-
*
|
|
1998
|
-
*
|
|
2349
|
+
* Each call pushes a value onto the internal subject and returns the shared, throttled observable.
|
|
2350
|
+
* Useful for debouncing repeated calls while sharing a single observable output.
|
|
2351
|
+
*
|
|
2352
|
+
* @example
|
|
2353
|
+
* ```ts
|
|
2354
|
+
* const pusher = asyncPusher<string>({ throttle: 100 });
|
|
2355
|
+
* const result$ = pusher('hello');
|
|
2356
|
+
* // subsequent calls within 100ms are throttled
|
|
2357
|
+
* pusher('world');
|
|
2358
|
+
* // clean up
|
|
2359
|
+
* pusher.destroy();
|
|
2360
|
+
* ```
|
|
2361
|
+
*
|
|
2362
|
+
* @param config - optional throttle, distinct, and pipe settings
|
|
2363
|
+
* @returns an async pusher function
|
|
1999
2364
|
*/ function asyncPusher() {
|
|
2000
2365
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2001
2366
|
var _config_throttle = config.throttle, throttle = _config_throttle === void 0 ? DEFAULT_ASYNC_PUSHER_THROTTLE : _config_throttle, cleanupObs = config.cleanupObs, _config_distinct = config.distinct, distinct = _config_distinct === void 0 ? true : _config_distinct, pipeObs = config.pipe;
|
|
@@ -2037,12 +2402,12 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
2037
2402
|
return pusher;
|
|
2038
2403
|
}
|
|
2039
2404
|
/**
|
|
2040
|
-
* Creates a
|
|
2405
|
+
* Creates a cached factory that lazily creates and returns an {@link AsyncPusher}.
|
|
2041
2406
|
*
|
|
2042
|
-
* The
|
|
2407
|
+
* The factory optionally accepts a cleanup observable — when it completes, the pusher is destroyed.
|
|
2043
2408
|
*
|
|
2044
|
-
* @param config
|
|
2045
|
-
* @returns
|
|
2409
|
+
* @param config - optional config passed to the underlying async pusher
|
|
2410
|
+
* @returns a cached factory that produces an async pusher
|
|
2046
2411
|
*/ function asyncPusherCache(config) {
|
|
2047
2412
|
return cachedGetter(function(cleanupObs) {
|
|
2048
2413
|
var pusher = asyncPusher(config);
|
|
@@ -2100,10 +2465,11 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2100
2465
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
|
|
2101
2466
|
}
|
|
2102
2467
|
/**
|
|
2103
|
-
* Creates a
|
|
2468
|
+
* Creates a function that takes a `Map` and combines the latest emissions from observables
|
|
2469
|
+
* created from each map value.
|
|
2104
2470
|
*
|
|
2105
|
-
* @param mapToObs
|
|
2106
|
-
* @returns
|
|
2471
|
+
* @param mapToObs - function to transform each map value into an observable
|
|
2472
|
+
* @returns a function that converts a Map to a combined observable of results
|
|
2107
2473
|
*/ function combineLatestFromMapValuesObsFn(mapToObs) {
|
|
2108
2474
|
var combineArrayFn = combineLatestFromArrayObsFn(mapToObs);
|
|
2109
2475
|
return function(latestMap) {
|
|
@@ -2113,13 +2479,37 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2113
2479
|
return combineArrayFn(mapValues);
|
|
2114
2480
|
};
|
|
2115
2481
|
}
|
|
2116
|
-
|
|
2482
|
+
/**
|
|
2483
|
+
* Creates a function that takes an array of values, maps each to an observable, and combines their latest emissions.
|
|
2484
|
+
*
|
|
2485
|
+
* Returns `of([])` for empty arrays.
|
|
2486
|
+
*
|
|
2487
|
+
* @param mapToObs - function to transform each value into an observable
|
|
2488
|
+
* @returns a function that converts an array to a combined observable
|
|
2489
|
+
*/ function combineLatestFromArrayObsFn(mapToObs) {
|
|
2117
2490
|
return function(latest) {
|
|
2118
2491
|
var newObs = latest.map(mapToObs);
|
|
2119
2492
|
return newObs.length ? combineLatest(newObs) : of([]);
|
|
2120
2493
|
};
|
|
2121
2494
|
}
|
|
2122
|
-
|
|
2495
|
+
/**
|
|
2496
|
+
* Combines the latest values from an object of observables into a single observable of resolved values.
|
|
2497
|
+
*
|
|
2498
|
+
* Each key in the input object maps to an observable (or static value). The result observable
|
|
2499
|
+
* emits an object with the same keys, where each value is the latest emission from its source.
|
|
2500
|
+
*
|
|
2501
|
+
* @example
|
|
2502
|
+
* ```ts
|
|
2503
|
+
* const result$ = combineLatestFromObject({
|
|
2504
|
+
* name: of('Alice'),
|
|
2505
|
+
* age: of(30)
|
|
2506
|
+
* });
|
|
2507
|
+
* // emits { name: 'Alice', age: 30 }
|
|
2508
|
+
* ```
|
|
2509
|
+
*
|
|
2510
|
+
* @param objectMap - an object whose values are observables or static values
|
|
2511
|
+
* @returns an observable that emits the resolved object
|
|
2512
|
+
*/ function combineLatestFromObject(objectMap) {
|
|
2123
2513
|
var pairs = allKeyValueTuples(objectMap);
|
|
2124
2514
|
var observables = pairs.map(function(x) {
|
|
2125
2515
|
return asObservable(x[1]).pipe(map(function(value) {
|
|
@@ -2140,23 +2530,40 @@ function combineLatestFromObject(objectMap) {
|
|
|
2140
2530
|
}
|
|
2141
2531
|
// MARK: Keys Map
|
|
2142
2532
|
/**
|
|
2143
|
-
*
|
|
2533
|
+
* RxJS operator that maps an array of items to a `Map<K, T>` using the provided key reader.
|
|
2144
2534
|
*
|
|
2145
|
-
* @param read
|
|
2146
|
-
* @returns
|
|
2535
|
+
* @param read - function to extract the key from each item
|
|
2536
|
+
* @returns an operator that converts an array into a keyed Map
|
|
2147
2537
|
*/ function keyValueMap(read) {
|
|
2148
2538
|
return map(keyValueMapFactory(read));
|
|
2149
2539
|
}
|
|
2150
2540
|
/**
|
|
2151
|
-
*
|
|
2541
|
+
* RxJS operator that maps an array of items to a `Map<K, T>` using a multi-key reader,
|
|
2542
|
+
* allowing each item to appear under multiple keys.
|
|
2152
2543
|
*
|
|
2153
|
-
* @param read
|
|
2154
|
-
* @returns
|
|
2544
|
+
* @param read - function to extract multiple keys from each item
|
|
2545
|
+
* @returns an operator that converts an array into a multi-keyed Map
|
|
2155
2546
|
*/ function multiKeyValueMap(read) {
|
|
2156
2547
|
return map(multiKeyValueMapFactory(read));
|
|
2157
2548
|
}
|
|
2158
2549
|
|
|
2159
|
-
|
|
2550
|
+
/**
|
|
2551
|
+
* RxJS operator that throws an error (or switches to an alternative observable) when too many
|
|
2552
|
+
* emissions occur within a rolling time period.
|
|
2553
|
+
*
|
|
2554
|
+
* Useful as a safety valve to detect infinite loops or runaway observables.
|
|
2555
|
+
*
|
|
2556
|
+
* @example
|
|
2557
|
+
* ```ts
|
|
2558
|
+
* source$.pipe(
|
|
2559
|
+
* errorOnEmissionsInPeriod({ maxEmissionsPerPeriod: 100, period: 1000 })
|
|
2560
|
+
* ).subscribe();
|
|
2561
|
+
* // throws if more than 100 emissions occur within 1 second
|
|
2562
|
+
* ```
|
|
2563
|
+
*
|
|
2564
|
+
* @param config - period duration, max emissions, and error/fallback handling
|
|
2565
|
+
* @returns an operator that monitors emission frequency
|
|
2566
|
+
*/ function errorOnEmissionsInPeriod(config) {
|
|
2160
2567
|
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;
|
|
2161
2568
|
var errorMessage = inputErrorMessage !== null && inputErrorMessage !== void 0 ? inputErrorMessage : 'errorOnEmissionsInPeriod(): Too many emissions in time period.';
|
|
2162
2569
|
var errorFactory = inputErrorFactory ? inputErrorFactory : !switchToObs ? function() {
|
|
@@ -2187,22 +2594,39 @@ function errorOnEmissionsInPeriod(config) {
|
|
|
2187
2594
|
};
|
|
2188
2595
|
}
|
|
2189
2596
|
|
|
2190
|
-
|
|
2597
|
+
/**
|
|
2598
|
+
* RxJS operator that checks whether the emitted `Set` contains all values from the given observable.
|
|
2599
|
+
*
|
|
2600
|
+
* @param valuesObs - observable of values to check against
|
|
2601
|
+
* @returns an operator that emits true if all values are contained in the set
|
|
2602
|
+
*/ function setContainsAllValuesFrom(valuesObs) {
|
|
2191
2603
|
return combineLatestMapFrom(valuesObs, function(set, values) {
|
|
2192
2604
|
return setContainsAllValues(set, values !== null && values !== void 0 ? values : []);
|
|
2193
2605
|
});
|
|
2194
2606
|
}
|
|
2195
|
-
|
|
2607
|
+
/**
|
|
2608
|
+
* RxJS operator that checks whether the emitted `Set` contains any value from the given observable.
|
|
2609
|
+
*
|
|
2610
|
+
* @param valuesObs - observable of values to check against
|
|
2611
|
+
* @returns an operator that emits true if any value is contained in the set
|
|
2612
|
+
*/ function setContainsAnyValueFrom(valuesObs) {
|
|
2196
2613
|
return combineLatestMapFrom(valuesObs, function(set, values) {
|
|
2197
2614
|
return setContainsAnyValue(set, values !== null && values !== void 0 ? values : []);
|
|
2198
2615
|
});
|
|
2199
2616
|
}
|
|
2200
|
-
|
|
2617
|
+
/**
|
|
2618
|
+
* RxJS operator that checks whether the emitted `Set` contains none of the values from the given observable.
|
|
2619
|
+
*
|
|
2620
|
+
* @param valuesObs - observable of values to check against
|
|
2621
|
+
* @returns an operator that emits true if no values are contained in the set
|
|
2622
|
+
*/ function setContainsNoValueFrom(valuesObs) {
|
|
2201
2623
|
return combineLatestMapFrom(valuesObs, function(set, values) {
|
|
2202
2624
|
return setContainsNoneOfValue(set, values !== null && values !== void 0 ? values : []);
|
|
2203
2625
|
});
|
|
2204
2626
|
}
|
|
2205
|
-
|
|
2627
|
+
/**
|
|
2628
|
+
* `distinctUntilChanged` variant for iterables that only emits when the contained values change.
|
|
2629
|
+
*/ function distinctUntilHasDifferentValues() {
|
|
2206
2630
|
return distinctUntilChanged(hasSameValues);
|
|
2207
2631
|
}
|
|
2208
2632
|
function distinctUntilItemsHaveDifferentValues(readValues) {
|
|
@@ -2213,7 +2637,24 @@ function distinctUntilItemsValueChanges(readValues, isEqualComparator) {
|
|
|
2213
2637
|
}
|
|
2214
2638
|
|
|
2215
2639
|
/**
|
|
2216
|
-
*
|
|
2640
|
+
* RxJS operator that filters an emitted array by a reactive search string.
|
|
2641
|
+
*
|
|
2642
|
+
* Combines the source array with the `search$` observable and applies the configured
|
|
2643
|
+
* search string filter function. When the search is null/undefined, all items pass through.
|
|
2644
|
+
*
|
|
2645
|
+
* @example
|
|
2646
|
+
* ```ts
|
|
2647
|
+
* const items$ = of(['apple', 'banana', 'cherry']);
|
|
2648
|
+
* const search$ = new BehaviorSubject<string>('an');
|
|
2649
|
+
*
|
|
2650
|
+
* items$.pipe(
|
|
2651
|
+
* filterWithSearchString({ filter: (x) => x, search$ })
|
|
2652
|
+
* ).subscribe(console.log);
|
|
2653
|
+
* // ['banana']
|
|
2654
|
+
* ```
|
|
2655
|
+
*
|
|
2656
|
+
* @param config - search filter configuration with filter function and search$ observable
|
|
2657
|
+
* @returns an operator that filters arrays by search string
|
|
2217
2658
|
*/ function filterWithSearchString(config) {
|
|
2218
2659
|
var filter = config.filter, search$ = config.search$;
|
|
2219
2660
|
var filterFactory = searchStringFilterFunction(filter);
|
|
@@ -2229,15 +2670,33 @@ function distinctUntilItemsValueChanges(readValues, isEqualComparator) {
|
|
|
2229
2670
|
}
|
|
2230
2671
|
|
|
2231
2672
|
/**
|
|
2232
|
-
*
|
|
2673
|
+
* Subscribes to the observable, calls the provided function with the first emitted value,
|
|
2674
|
+
* then automatically unsubscribes.
|
|
2233
2675
|
*
|
|
2234
|
-
* @param
|
|
2676
|
+
* @param obs - the source observable
|
|
2677
|
+
* @param useFn - function to call with the first value
|
|
2235
2678
|
*/ function useFirst(obs, useFn) {
|
|
2236
2679
|
obs.pipe(first()).subscribe(useFn);
|
|
2237
2680
|
}
|
|
2238
2681
|
|
|
2239
2682
|
/**
|
|
2240
|
-
* Creates a switchMap operator that
|
|
2683
|
+
* Creates a `switchMap` operator that subscribes to the {@link LoadingContext.stream$} of each emitted {@link LoadingContext},
|
|
2684
|
+
* emitting `undefined` when the context is nullish.
|
|
2685
|
+
*
|
|
2686
|
+
* Useful for flattening an observable of optional loading contexts into a single stream of loading events.
|
|
2687
|
+
*
|
|
2688
|
+
* @example
|
|
2689
|
+
* ```ts
|
|
2690
|
+
* const context$ = new BehaviorSubject<Maybe<LoadingContext>>(myLoadingContext);
|
|
2691
|
+
*
|
|
2692
|
+
* const events$ = context$.pipe(
|
|
2693
|
+
* switchMapMaybeLoadingContextStream()
|
|
2694
|
+
* );
|
|
2695
|
+
* // emits LoadingContextEvent values from myLoadingContext.stream$
|
|
2696
|
+
* // emits undefined when context$ emits null/undefined
|
|
2697
|
+
* ```
|
|
2698
|
+
*
|
|
2699
|
+
* @returns an RxJS operator that switches to the stream$ of each non-null LoadingContext
|
|
2241
2700
|
*/ function switchMapMaybeLoadingContextStream() {
|
|
2242
2701
|
return switchMap(function(x) {
|
|
2243
2702
|
return x != null ? x.stream$ : of(undefined);
|
|
@@ -2317,20 +2776,33 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2317
2776
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
|
|
2318
2777
|
}
|
|
2319
2778
|
/**
|
|
2320
|
-
*
|
|
2779
|
+
* Compares two {@link LoadingState} instances for shallow equality across all key properties.
|
|
2321
2780
|
*
|
|
2322
|
-
* @
|
|
2323
|
-
*
|
|
2324
|
-
*
|
|
2781
|
+
* @example
|
|
2782
|
+
* ```ts
|
|
2783
|
+
* const a = successResult('hello');
|
|
2784
|
+
* const b = successResult('hello');
|
|
2785
|
+
* isLoadingStateEqual(a, b); // true (same value reference is not required, but same primitive is)
|
|
2786
|
+
*
|
|
2787
|
+
* const c = beginLoading();
|
|
2788
|
+
* isLoadingStateEqual(a, c); // false
|
|
2789
|
+
* ```
|
|
2790
|
+
*
|
|
2791
|
+
* @param a - first loading state
|
|
2792
|
+
* @param b - second loading state
|
|
2793
|
+
* @returns true if loading, loadingProgress, error, and value are all strictly equal
|
|
2325
2794
|
*/ function isLoadingStateEqual(a, b) {
|
|
2326
2795
|
return a.loading === b.loading && a.loadingProgress === b.loadingProgress && a.error === b.error && a.value === b.value;
|
|
2327
2796
|
}
|
|
2328
2797
|
/**
|
|
2329
|
-
*
|
|
2798
|
+
* Compares the metadata (loading flag, loading progress, and error) of two {@link LoadingErrorPair} instances,
|
|
2799
|
+
* using loose equality for loading and nullish-aware comparison for progress and error.
|
|
2800
|
+
*
|
|
2801
|
+
* Does not compare the `value` property — only structural metadata.
|
|
2330
2802
|
*
|
|
2331
|
-
* @param a
|
|
2332
|
-
* @param b
|
|
2333
|
-
* @returns
|
|
2803
|
+
* @param a - first loading error pair
|
|
2804
|
+
* @param b - second loading error pair
|
|
2805
|
+
* @returns true if both pairs have equivalent metadata
|
|
2334
2806
|
*/ function isLoadingStateMetadataEqual(a, b) {
|
|
2335
2807
|
return a.loading == b.loading && valuesAreBothNullishOrEquivalent(a.loadingProgress, b.loadingProgress) && valuesAreBothNullishOrEquivalent(a.error, b.error);
|
|
2336
2808
|
}
|
|
@@ -2353,10 +2825,21 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2353
2825
|
*/ LoadingStateType["ERROR"] = "error";
|
|
2354
2826
|
})(LoadingStateType || (LoadingStateType = {}));
|
|
2355
2827
|
/**
|
|
2356
|
-
*
|
|
2828
|
+
* Determines the current {@link LoadingStateType} of a {@link LoadingState}.
|
|
2357
2829
|
*
|
|
2358
|
-
*
|
|
2359
|
-
*
|
|
2830
|
+
* Returns `LOADING` if still loading, `SUCCESS` if finished with a value key,
|
|
2831
|
+
* `ERROR` if finished with an error key, or `IDLE` if finished with neither.
|
|
2832
|
+
*
|
|
2833
|
+
* @example
|
|
2834
|
+
* ```ts
|
|
2835
|
+
* loadingStateType(beginLoading()); // LoadingStateType.LOADING
|
|
2836
|
+
* loadingStateType(successResult(42)); // LoadingStateType.SUCCESS
|
|
2837
|
+
* loadingStateType(errorResult(new Error())); // LoadingStateType.ERROR
|
|
2838
|
+
* loadingStateType({ loading: false }); // LoadingStateType.IDLE
|
|
2839
|
+
* ```
|
|
2840
|
+
*
|
|
2841
|
+
* @param loadingState - the loading state to classify
|
|
2842
|
+
* @returns the corresponding {@link LoadingStateType}
|
|
2360
2843
|
*/ function loadingStateType(loadingState) {
|
|
2361
2844
|
var isLoading = !isLoadingStateFinishedLoading(loadingState);
|
|
2362
2845
|
var type;
|
|
@@ -2373,7 +2856,23 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
2373
2856
|
}
|
|
2374
2857
|
return type;
|
|
2375
2858
|
}
|
|
2376
|
-
|
|
2859
|
+
/**
|
|
2860
|
+
* Whether the given {@link LoadingState} has finished loading.
|
|
2861
|
+
*
|
|
2862
|
+
* Returns `true` when `loading` is explicitly `false`, or when `loading` is not `true`
|
|
2863
|
+
* and either a value, error, or `null` value is present.
|
|
2864
|
+
*
|
|
2865
|
+
* @example
|
|
2866
|
+
* ```ts
|
|
2867
|
+
* isLoadingStateFinishedLoading(successResult('done')); // true
|
|
2868
|
+
* isLoadingStateFinishedLoading(beginLoading()); // false
|
|
2869
|
+
* isLoadingStateFinishedLoading({ loading: false }); // true
|
|
2870
|
+
* isLoadingStateFinishedLoading(null); // false
|
|
2871
|
+
* ```
|
|
2872
|
+
*
|
|
2873
|
+
* @param state - the loading state to check (may be null/undefined)
|
|
2874
|
+
* @returns true if loading is complete
|
|
2875
|
+
*/ function isLoadingStateFinishedLoading(state) {
|
|
2377
2876
|
if (state) {
|
|
2378
2877
|
var loading = state.loading;
|
|
2379
2878
|
if (loading === true) {
|
|
@@ -2386,7 +2885,16 @@ function isLoadingStateFinishedLoading(state) {
|
|
|
2386
2885
|
}
|
|
2387
2886
|
}
|
|
2388
2887
|
/**
|
|
2389
|
-
*
|
|
2888
|
+
* Creates an idle {@link LoadingState} with `loading: false` and no value or error.
|
|
2889
|
+
*
|
|
2890
|
+
* Represents a state where no loading has been initiated yet.
|
|
2891
|
+
*
|
|
2892
|
+
* @example
|
|
2893
|
+
* ```ts
|
|
2894
|
+
* const state = idleLoadingState();
|
|
2895
|
+
* // { loading: false }
|
|
2896
|
+
* loadingStateType(state); // LoadingStateType.IDLE
|
|
2897
|
+
* ```
|
|
2390
2898
|
*/ function idleLoadingState() {
|
|
2391
2899
|
return {
|
|
2392
2900
|
loading: false
|
|
@@ -2399,7 +2907,13 @@ function beginLoading(state) {
|
|
|
2399
2907
|
loading: true
|
|
2400
2908
|
};
|
|
2401
2909
|
}
|
|
2402
|
-
|
|
2910
|
+
/**
|
|
2911
|
+
* Creates a {@link PageLoadingState} that is loading for the given page number.
|
|
2912
|
+
*
|
|
2913
|
+
* @param page - the page number being loaded
|
|
2914
|
+
* @param state - optional partial state to merge
|
|
2915
|
+
* @returns a page loading state with `loading: true`
|
|
2916
|
+
*/ function beginLoadingPage(page, state) {
|
|
2403
2917
|
return state ? _object_spread_props$6(_object_spread$6({
|
|
2404
2918
|
page: page
|
|
2405
2919
|
}, state), {
|
|
@@ -2409,45 +2923,100 @@ function beginLoadingPage(page, state) {
|
|
|
2409
2923
|
loading: true
|
|
2410
2924
|
};
|
|
2411
2925
|
}
|
|
2412
|
-
|
|
2926
|
+
/**
|
|
2927
|
+
* Creates a successful {@link LoadingState} with the given value and `loading: false`.
|
|
2928
|
+
*
|
|
2929
|
+
* @example
|
|
2930
|
+
* ```ts
|
|
2931
|
+
* const state = successResult({ name: 'Alice' });
|
|
2932
|
+
* // { value: { name: 'Alice' }, loading: false }
|
|
2933
|
+
* ```
|
|
2934
|
+
*
|
|
2935
|
+
* @param value - the loaded value
|
|
2936
|
+
* @returns a loading state representing a successful result
|
|
2937
|
+
*/ function successResult(value) {
|
|
2413
2938
|
return {
|
|
2414
2939
|
value: value,
|
|
2415
2940
|
loading: false
|
|
2416
2941
|
};
|
|
2417
2942
|
}
|
|
2418
|
-
|
|
2943
|
+
/**
|
|
2944
|
+
* Creates a successful {@link PageLoadingState} for a specific page.
|
|
2945
|
+
*
|
|
2946
|
+
* @param page - the page number
|
|
2947
|
+
* @param value - the loaded value
|
|
2948
|
+
* @returns a page loading state representing success
|
|
2949
|
+
*/ function successPageResult(page, value) {
|
|
2419
2950
|
return _object_spread_props$6(_object_spread$6({}, successResult(value)), {
|
|
2420
2951
|
page: page
|
|
2421
2952
|
});
|
|
2422
2953
|
}
|
|
2423
|
-
|
|
2954
|
+
/**
|
|
2955
|
+
* Creates a {@link LoadingState} representing an error with `loading: false`.
|
|
2956
|
+
*
|
|
2957
|
+
* Converts the input error to a {@link ReadableError} via {@link toReadableError}.
|
|
2958
|
+
*
|
|
2959
|
+
* @example
|
|
2960
|
+
* ```ts
|
|
2961
|
+
* const state = errorResult(new Error('Not found'));
|
|
2962
|
+
* // { error: { message: 'Not found', ... }, loading: false }
|
|
2963
|
+
* ```
|
|
2964
|
+
*
|
|
2965
|
+
* @param error - the error to wrap (string, Error, or ReadableError)
|
|
2966
|
+
* @returns a loading state representing an error
|
|
2967
|
+
*/ function errorResult(error) {
|
|
2424
2968
|
return {
|
|
2425
2969
|
error: toReadableError(error),
|
|
2426
2970
|
loading: false
|
|
2427
2971
|
};
|
|
2428
2972
|
}
|
|
2429
|
-
|
|
2973
|
+
/**
|
|
2974
|
+
* Creates a {@link PageLoadingState} representing an error for a specific page.
|
|
2975
|
+
*
|
|
2976
|
+
* @param page - the page number
|
|
2977
|
+
* @param error - the error to include
|
|
2978
|
+
* @returns a page loading state representing an error
|
|
2979
|
+
*/ function errorPageResult(page, error) {
|
|
2430
2980
|
return _object_spread_props$6(_object_spread$6({}, errorResult(error)), {
|
|
2431
2981
|
page: page
|
|
2432
2982
|
});
|
|
2433
2983
|
}
|
|
2434
2984
|
/**
|
|
2435
|
-
*
|
|
2985
|
+
* Whether any of the given {@link LoadingState} instances are currently loading.
|
|
2436
2986
|
*
|
|
2437
|
-
* @
|
|
2438
|
-
*
|
|
2987
|
+
* @example
|
|
2988
|
+
* ```ts
|
|
2989
|
+
* isAnyLoadingStateInLoadingState([successResult(1), beginLoading()]); // true
|
|
2990
|
+
* isAnyLoadingStateInLoadingState([successResult(1), successResult(2)]); // false
|
|
2991
|
+
* ```
|
|
2992
|
+
*
|
|
2993
|
+
* @param states - array of loading states to check
|
|
2994
|
+
* @returns true if at least one state is loading
|
|
2439
2995
|
*/ function isAnyLoadingStateInLoadingState(states) {
|
|
2440
2996
|
return reduceBooleansWithOr(states.map(isLoadingStateLoading), false);
|
|
2441
2997
|
}
|
|
2442
2998
|
/**
|
|
2443
|
-
*
|
|
2999
|
+
* Whether all given {@link LoadingState} instances have finished loading.
|
|
2444
3000
|
*
|
|
2445
|
-
* @
|
|
2446
|
-
*
|
|
3001
|
+
* @example
|
|
3002
|
+
* ```ts
|
|
3003
|
+
* areAllLoadingStatesFinishedLoading([successResult(1), successResult(2)]); // true
|
|
3004
|
+
* areAllLoadingStatesFinishedLoading([successResult(1), beginLoading()]); // false
|
|
3005
|
+
* ```
|
|
3006
|
+
*
|
|
3007
|
+
* @param states - array of loading states to check
|
|
3008
|
+
* @returns true if every state has finished loading
|
|
2447
3009
|
*/ function areAllLoadingStatesFinishedLoading(states) {
|
|
2448
3010
|
return reduceBooleansWithAnd(states.map(isLoadingStateFinishedLoading), true);
|
|
2449
3011
|
}
|
|
2450
|
-
|
|
3012
|
+
/**
|
|
3013
|
+
* Creates a predicate function that checks whether a {@link LoadingState} matches the given {@link LoadingStateType}.
|
|
3014
|
+
*
|
|
3015
|
+
* When the target type is `IDLE`, returns `true` for null/undefined states.
|
|
3016
|
+
*
|
|
3017
|
+
* @param type - the loading state type to match against
|
|
3018
|
+
* @returns a predicate function for the given type
|
|
3019
|
+
*/ function isLoadingStateWithStateType(type) {
|
|
2451
3020
|
var defaultResult = type === LoadingStateType.IDLE ? true : false;
|
|
2452
3021
|
return function(state) {
|
|
2453
3022
|
if (state) {
|
|
@@ -2485,10 +3054,17 @@ function isLoadingStateWithStateType(type) {
|
|
|
2485
3054
|
* @returns
|
|
2486
3055
|
*/ var isLoadingStateInErrorState = isLoadingStateWithStateType(LoadingStateType.ERROR);
|
|
2487
3056
|
/**
|
|
2488
|
-
*
|
|
3057
|
+
* Type guard that checks whether a {@link LoadingState} has a non-undefined value, regardless of loading status.
|
|
2489
3058
|
*
|
|
2490
|
-
* @
|
|
2491
|
-
*
|
|
3059
|
+
* @example
|
|
3060
|
+
* ```ts
|
|
3061
|
+
* isLoadingStateWithDefinedValue(successResult('hello')); // true
|
|
3062
|
+
* isLoadingStateWithDefinedValue(successResult(null)); // true (null is defined)
|
|
3063
|
+
* isLoadingStateWithDefinedValue(beginLoading()); // false
|
|
3064
|
+
* ```
|
|
3065
|
+
*
|
|
3066
|
+
* @param state - the loading state to check
|
|
3067
|
+
* @returns true if the state has a defined (non-undefined) value
|
|
2492
3068
|
*/ function isLoadingStateWithDefinedValue(state) {
|
|
2493
3069
|
if (state) {
|
|
2494
3070
|
return state.value !== undefined;
|
|
@@ -2497,10 +3073,16 @@ function isLoadingStateWithStateType(type) {
|
|
|
2497
3073
|
}
|
|
2498
3074
|
}
|
|
2499
3075
|
/**
|
|
2500
|
-
*
|
|
3076
|
+
* Type guard that checks whether a {@link LoadingState} has a non-null error, regardless of loading status.
|
|
2501
3077
|
*
|
|
2502
|
-
* @
|
|
2503
|
-
*
|
|
3078
|
+
* @example
|
|
3079
|
+
* ```ts
|
|
3080
|
+
* isLoadingStateWithError(errorResult(new Error('fail'))); // true
|
|
3081
|
+
* isLoadingStateWithError(successResult('ok')); // false
|
|
3082
|
+
* ```
|
|
3083
|
+
*
|
|
3084
|
+
* @param state - the loading state to check
|
|
3085
|
+
* @returns true if the state has an error
|
|
2504
3086
|
*/ function isLoadingStateWithError(state) {
|
|
2505
3087
|
if (state) {
|
|
2506
3088
|
return state.error != null;
|
|
@@ -2509,10 +3091,10 @@ function isLoadingStateWithStateType(type) {
|
|
|
2509
3091
|
}
|
|
2510
3092
|
}
|
|
2511
3093
|
/**
|
|
2512
|
-
*
|
|
3094
|
+
* Type guard that checks whether a {@link LoadingState} has finished loading and has a defined value.
|
|
2513
3095
|
*
|
|
2514
|
-
* @param state
|
|
2515
|
-
* @returns
|
|
3096
|
+
* @param state - the loading state to check
|
|
3097
|
+
* @returns true if finished loading with a non-undefined value
|
|
2516
3098
|
*/ function isLoadingStateFinishedLoadingWithDefinedValue(state) {
|
|
2517
3099
|
if (state) {
|
|
2518
3100
|
return isLoadingStateFinishedLoading(state) && state.value !== undefined;
|
|
@@ -2521,10 +3103,10 @@ function isLoadingStateWithStateType(type) {
|
|
|
2521
3103
|
}
|
|
2522
3104
|
}
|
|
2523
3105
|
/**
|
|
2524
|
-
*
|
|
3106
|
+
* Type guard that checks whether a {@link LoadingState} has finished loading and has an error.
|
|
2525
3107
|
*
|
|
2526
|
-
* @param state
|
|
2527
|
-
* @returns
|
|
3108
|
+
* @param state - the loading state to check
|
|
3109
|
+
* @returns true if finished loading with an error
|
|
2528
3110
|
*/ function isLoadingStateFinishedLoadingWithError(state) {
|
|
2529
3111
|
if (state) {
|
|
2530
3112
|
return isLoadingStateFinishedLoading(state) && state.error != null;
|
|
@@ -2533,12 +3115,26 @@ function isLoadingStateWithStateType(type) {
|
|
|
2533
3115
|
}
|
|
2534
3116
|
}
|
|
2535
3117
|
/**
|
|
2536
|
-
*
|
|
3118
|
+
* Compares the metadata (page, loading, error) of two {@link PageLoadingState} instances for equivalence.
|
|
2537
3119
|
*
|
|
2538
|
-
*
|
|
3120
|
+
* Does not compare values — only structural metadata.
|
|
3121
|
+
*
|
|
3122
|
+
* @example
|
|
3123
|
+
* ```ts
|
|
3124
|
+
* isPageLoadingStateMetadataEqual(
|
|
3125
|
+
* { page: 1, loading: true },
|
|
3126
|
+
* { page: 1, loading: true }
|
|
3127
|
+
* ); // true
|
|
2539
3128
|
*
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
3129
|
+
* isPageLoadingStateMetadataEqual(
|
|
3130
|
+
* { page: 1 },
|
|
3131
|
+
* { page: 2 }
|
|
3132
|
+
* ); // false
|
|
3133
|
+
* ```
|
|
3134
|
+
*
|
|
3135
|
+
* @param a - first page loading state
|
|
3136
|
+
* @param b - second page loading state
|
|
3137
|
+
* @returns true if metadata is equivalent
|
|
2542
3138
|
*/ function isPageLoadingStateMetadataEqual(a, b) {
|
|
2543
3139
|
return valuesAreBothNullishOrEquivalent(a.page, b.page) && a.loading == b.loading && valuesAreBothNullishOrEquivalent(a.error, b.error);
|
|
2544
3140
|
}
|
|
@@ -2595,7 +3191,13 @@ function mergeLoadingStates() {
|
|
|
2595
3191
|
return result;
|
|
2596
3192
|
}
|
|
2597
3193
|
/**
|
|
2598
|
-
* Returns a
|
|
3194
|
+
* Returns a copy of the state with the value and error cleared, and `loading` set to the given flag.
|
|
3195
|
+
*
|
|
3196
|
+
* Useful for resetting a state back to loading or idle without losing other metadata (e.g., page).
|
|
3197
|
+
*
|
|
3198
|
+
* @param state - the state to copy metadata from
|
|
3199
|
+
* @param loading - whether to mark as loading (defaults to true)
|
|
3200
|
+
* @returns a new state with value/error cleared
|
|
2599
3201
|
*/ function mergeLoadingStateWithLoading(state) {
|
|
2600
3202
|
var loading = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
2601
3203
|
return _object_spread_props$6(_object_spread$6({}, state), {
|
|
@@ -2605,7 +3207,11 @@ function mergeLoadingStates() {
|
|
|
2605
3207
|
});
|
|
2606
3208
|
}
|
|
2607
3209
|
/**
|
|
2608
|
-
* Returns a
|
|
3210
|
+
* Returns a copy of the state with the given value, `loading: false`, and error cleared.
|
|
3211
|
+
*
|
|
3212
|
+
* @param state - the state to copy metadata from
|
|
3213
|
+
* @param value - the new value to set
|
|
3214
|
+
* @returns a new state representing success
|
|
2609
3215
|
*/ function mergeLoadingStateWithValue(state, value) {
|
|
2610
3216
|
return _object_spread_props$6(_object_spread$6({}, state), {
|
|
2611
3217
|
value: value !== null && value !== void 0 ? value : undefined,
|
|
@@ -2614,14 +3220,28 @@ function mergeLoadingStates() {
|
|
|
2614
3220
|
});
|
|
2615
3221
|
}
|
|
2616
3222
|
/**
|
|
2617
|
-
* Returns a
|
|
3223
|
+
* Returns a copy of the state with the given error and `loading: false`.
|
|
3224
|
+
*
|
|
3225
|
+
* @param state - the state to copy metadata from
|
|
3226
|
+
* @param error - the error to set
|
|
3227
|
+
* @returns a new state representing an error
|
|
2618
3228
|
*/ function mergeLoadingStateWithError(state, error) {
|
|
2619
3229
|
return _object_spread_props$6(_object_spread$6({}, state), {
|
|
2620
3230
|
loading: false,
|
|
2621
3231
|
error: error
|
|
2622
3232
|
});
|
|
2623
3233
|
}
|
|
2624
|
-
|
|
3234
|
+
/**
|
|
3235
|
+
* Maps multiple {@link LoadingState} results into a single state using a value mapping or state mapping function.
|
|
3236
|
+
*
|
|
3237
|
+
* Returns `undefined` if any input is still loading or has an error.
|
|
3238
|
+
*
|
|
3239
|
+
* @param input - array of loading states to combine
|
|
3240
|
+
* @param config - mapping configuration with either `mapValues` or `mapState`
|
|
3241
|
+
* @returns the combined loading state, or undefined if inputs are not ready
|
|
3242
|
+
*
|
|
3243
|
+
* @throws {Error} When neither `mapValues` nor `mapState` is provided in the config.
|
|
3244
|
+
*/ function mapMultipleLoadingStateResults(input, config) {
|
|
2625
3245
|
var mapValues = config.mapValues, mapState = config.mapState;
|
|
2626
3246
|
var loading = isAnyLoadingStateInLoadingState(input);
|
|
2627
3247
|
var error = input.map(function(x) {
|
|
@@ -2667,7 +3287,13 @@ function mapLoadingStateResults(input, config) {
|
|
|
2667
3287
|
}
|
|
2668
3288
|
return result;
|
|
2669
3289
|
}
|
|
2670
|
-
|
|
3290
|
+
/**
|
|
3291
|
+
* Creates a function that extracts and maps the value from a {@link LoadingState}, returning undefined
|
|
3292
|
+
* when the state has no value.
|
|
3293
|
+
*
|
|
3294
|
+
* @param mapFn - function to transform the value and state into the output type
|
|
3295
|
+
* @returns a function that accepts a loading state and returns the mapped value or undefined
|
|
3296
|
+
*/ function mapLoadingStateValueFunction(mapFn) {
|
|
2671
3297
|
return function(state) {
|
|
2672
3298
|
var result;
|
|
2673
3299
|
if (state.value != null) {
|
|
@@ -3111,7 +3737,12 @@ function distinctLoadingState(inputConfig) {
|
|
|
3111
3737
|
});
|
|
3112
3738
|
}
|
|
3113
3739
|
|
|
3114
|
-
|
|
3740
|
+
/**
|
|
3741
|
+
* Default function for converting a {@link LoadingState} into a {@link LoadingStateContextEvent}.
|
|
3742
|
+
*
|
|
3743
|
+
* Determines the `loading` flag based on whether an error is present, whether the value is defined,
|
|
3744
|
+
* and the `showLoadingOnUndefinedValue` setting. Loading progress is only included while loading.
|
|
3745
|
+
*/ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION(state, input) {
|
|
3115
3746
|
var showLoadingOnUndefinedValue = input.showLoadingOnUndefinedValue;
|
|
3116
3747
|
var error = state.error, value = state.value, loadingProgress = state.loadingProgress;
|
|
3117
3748
|
var loading = false;
|
|
@@ -3130,10 +3761,32 @@ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_E
|
|
|
3130
3761
|
};
|
|
3131
3762
|
};
|
|
3132
3763
|
/**
|
|
3133
|
-
* Creates a new
|
|
3134
|
-
|
|
3135
|
-
*
|
|
3136
|
-
* @
|
|
3764
|
+
* Creates a new {@link MutableLoadingStateContext} that wraps an observable of {@link LoadingState} values
|
|
3765
|
+
* and exposes reactive accessors for the loading flag, current value, errors, and state stream.
|
|
3766
|
+
*
|
|
3767
|
+
* Accepts either a raw observable or a {@link LoadingStateContextConfig} for fine-grained control
|
|
3768
|
+
* over how loading events are derived from the state.
|
|
3769
|
+
*
|
|
3770
|
+
* @example
|
|
3771
|
+
* ```ts
|
|
3772
|
+
* // Create a context from a state observable
|
|
3773
|
+
* const context = loadingStateContext(myLoadingState$);
|
|
3774
|
+
*
|
|
3775
|
+
* // Subscribe to the loading flag
|
|
3776
|
+
* context.loading$.subscribe((loading) => console.log('Loading:', loading));
|
|
3777
|
+
*
|
|
3778
|
+
* // Access the value after loading completes
|
|
3779
|
+
* context.value$.subscribe((value) => console.log('Value:', value));
|
|
3780
|
+
*
|
|
3781
|
+
* // Update the state observable later
|
|
3782
|
+
* context.setStateObs(newLoadingState$);
|
|
3783
|
+
*
|
|
3784
|
+
* // Clean up
|
|
3785
|
+
* context.destroy();
|
|
3786
|
+
* ```
|
|
3787
|
+
*
|
|
3788
|
+
* @param input - optional observable or config to initialize the context
|
|
3789
|
+
* @returns a mutable loading state context with reactive accessors
|
|
3137
3790
|
*/ function loadingStateContext(input) {
|
|
3138
3791
|
var _ref, _ref1;
|
|
3139
3792
|
var _config = input && isObservable(input) ? {
|
|
@@ -3189,22 +3842,51 @@ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_E
|
|
|
3189
3842
|
}
|
|
3190
3843
|
|
|
3191
3844
|
/**
|
|
3192
|
-
*
|
|
3845
|
+
* Whether the {@link ListLoadingState} has no value or an empty array.
|
|
3193
3846
|
*
|
|
3194
|
-
*
|
|
3195
|
-
*
|
|
3847
|
+
* Returns true if the value is nullish or has zero length, regardless of loading status.
|
|
3848
|
+
*
|
|
3849
|
+
* @example
|
|
3850
|
+
* ```ts
|
|
3851
|
+
* isListLoadingStateWithEmptyValue(successResult([])); // true
|
|
3852
|
+
* isListLoadingStateWithEmptyValue(successResult([1, 2])); // false
|
|
3853
|
+
* isListLoadingStateWithEmptyValue(beginLoading()); // true (no value)
|
|
3854
|
+
* ```
|
|
3855
|
+
*
|
|
3856
|
+
* @param listLoadingState - the list loading state to check
|
|
3857
|
+
* @returns true if the value is empty or absent
|
|
3196
3858
|
*/ function isListLoadingStateWithEmptyValue(listLoadingState) {
|
|
3197
3859
|
return Boolean(!listLoadingState.value || !listLoadingState.value.length);
|
|
3198
3860
|
}
|
|
3199
3861
|
/**
|
|
3200
|
-
*
|
|
3862
|
+
* RxJS operator that maps each emitted {@link ListLoadingState} to a boolean indicating whether the list is empty.
|
|
3201
3863
|
*
|
|
3202
|
-
* @
|
|
3864
|
+
* @example
|
|
3865
|
+
* ```ts
|
|
3866
|
+
* of(successResult([])).pipe(
|
|
3867
|
+
* mapIsListLoadingStateWithEmptyValue()
|
|
3868
|
+
* ).subscribe((isEmpty) => console.log(isEmpty)); // true
|
|
3869
|
+
* ```
|
|
3870
|
+
*
|
|
3871
|
+
* @returns an operator that emits true when the list value is empty or absent
|
|
3203
3872
|
*/ function mapIsListLoadingStateWithEmptyValue() {
|
|
3204
3873
|
return map(isListLoadingStateWithEmptyValue);
|
|
3205
3874
|
}
|
|
3206
3875
|
/**
|
|
3207
|
-
* Wraps an observable
|
|
3876
|
+
* Wraps an observable and converts its emissions into a {@link PageLoadingState} for the given page number.
|
|
3877
|
+
*
|
|
3878
|
+
* Uses {@link loadingStateFromObs} internally and attaches the page number to each emitted state.
|
|
3879
|
+
*
|
|
3880
|
+
* @example
|
|
3881
|
+
* ```ts
|
|
3882
|
+
* const pageState$ = pageLoadingStateFromObs(fetchItems$, false, 2);
|
|
3883
|
+
* // emits: { loading: true, page: 2 }, then { value: items, loading: false, page: 2 }
|
|
3884
|
+
* ```
|
|
3885
|
+
*
|
|
3886
|
+
* @param obs - the source observable to wrap
|
|
3887
|
+
* @param firstOnly - if true, only takes the first value
|
|
3888
|
+
* @param page - the page number to attach (defaults to 0)
|
|
3889
|
+
* @returns an observable of page loading states
|
|
3208
3890
|
*/ function pageLoadingStateFromObs(obs, firstOnly) {
|
|
3209
3891
|
var page = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
|
|
3210
3892
|
return loadingStateFromObs(obs, firstOnly).pipe(map(function(x) {
|
|
@@ -3213,11 +3895,23 @@ var DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION = function DEFAULT_LOADING_E
|
|
|
3213
3895
|
}));
|
|
3214
3896
|
}
|
|
3215
3897
|
/**
|
|
3216
|
-
*
|
|
3898
|
+
* RxJS operator that extracts the array value from a finished {@link ListLoadingState},
|
|
3899
|
+
* defaulting to an empty array when no value is present.
|
|
3217
3900
|
*
|
|
3218
|
-
*
|
|
3901
|
+
* Combines {@link valueFromFinishedLoadingState} with a default of `[]`.
|
|
3219
3902
|
*
|
|
3220
|
-
* @
|
|
3903
|
+
* @example
|
|
3904
|
+
* ```ts
|
|
3905
|
+
* of(successResult([1, 2, 3])).pipe(
|
|
3906
|
+
* arrayValueFromFinishedLoadingState()
|
|
3907
|
+
* ).subscribe((items) => console.log(items)); // [1, 2, 3]
|
|
3908
|
+
*
|
|
3909
|
+
* of(successResult(null)).pipe(
|
|
3910
|
+
* arrayValueFromFinishedLoadingState()
|
|
3911
|
+
* ).subscribe((items) => console.log(items)); // []
|
|
3912
|
+
* ```
|
|
3913
|
+
*
|
|
3914
|
+
* @returns an operator that emits the array value or an empty array
|
|
3221
3915
|
*/ function arrayValueFromFinishedLoadingState() {
|
|
3222
3916
|
return function(obs) {
|
|
3223
3917
|
return obs.pipe(valueFromFinishedLoadingState(function() {
|
|
@@ -3278,10 +3972,32 @@ function _type_of$2(obj) {
|
|
|
3278
3972
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3279
3973
|
}
|
|
3280
3974
|
/**
|
|
3281
|
-
* Creates a
|
|
3975
|
+
* Creates a {@link MutableListLoadingStateContext} that wraps a {@link ListLoadingState} observable
|
|
3976
|
+
* and provides list-specific reactive accessors like `isEmpty$` and `list$`.
|
|
3977
|
+
*
|
|
3978
|
+
* Extends {@link loadingStateContext} with list-aware behavior, including optional array length limiting
|
|
3979
|
+
* via {@link LimitArrayConfig} and empty-state detection streams.
|
|
3980
|
+
*
|
|
3981
|
+
* @example
|
|
3982
|
+
* ```ts
|
|
3983
|
+
* const context = listLoadingStateContext<string>();
|
|
3984
|
+
*
|
|
3985
|
+
* // Set a state observable
|
|
3986
|
+
* context.setStateObs(of(successResult(['a', 'b', 'c'])));
|
|
3282
3987
|
*
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3988
|
+
* // Access the list (defaults to [] when undefined)
|
|
3989
|
+
* context.list$.subscribe((list) => console.log(list));
|
|
3990
|
+
* // => ['a', 'b', 'c']
|
|
3991
|
+
*
|
|
3992
|
+
* // Check if the list is empty
|
|
3993
|
+
* context.isEmpty$.subscribe((empty) => console.log('Empty:', empty));
|
|
3994
|
+
* // => false
|
|
3995
|
+
*
|
|
3996
|
+
* context.destroy();
|
|
3997
|
+
* ```
|
|
3998
|
+
*
|
|
3999
|
+
* @param input - optional observable or config to initialize the context
|
|
4000
|
+
* @returns a mutable list loading state context
|
|
3285
4001
|
*/ function listLoadingStateContext(input) {
|
|
3286
4002
|
var limitArrayConfig = (typeof input === "undefined" ? "undefined" : _type_of$2(input)) === 'object' ? input : undefined;
|
|
3287
4003
|
var loadingState = loadingStateContext(_object_spread_props$4(_object_spread$4({}, input), {
|
|
@@ -3385,7 +4101,21 @@ function _object_spread_props$3(target, source) {
|
|
|
3385
4101
|
return target;
|
|
3386
4102
|
}
|
|
3387
4103
|
/**
|
|
3388
|
-
* Simple LoadingContext implementation
|
|
4104
|
+
* Simple imperative {@link LoadingContext} implementation backed by a {@link BehaviorSubject}.
|
|
4105
|
+
*
|
|
4106
|
+
* Provides methods to manually set loading, success, and error states. Useful in components
|
|
4107
|
+
* or services that need to drive a loading indicator without a dedicated state observable.
|
|
4108
|
+
*
|
|
4109
|
+
* @example
|
|
4110
|
+
* ```ts
|
|
4111
|
+
* const context = new SimpleLoadingContext();
|
|
4112
|
+
* // context starts in loading state by default
|
|
4113
|
+
*
|
|
4114
|
+
* context.setSuccess(); // marks loading as complete
|
|
4115
|
+
* context.setError({ message: 'Something went wrong' }); // sets an error
|
|
4116
|
+
* context.clearError(); // clears the error but preserves loading state
|
|
4117
|
+
* context.destroy(); // completes the internal subject
|
|
4118
|
+
* ```
|
|
3389
4119
|
*/ var SimpleLoadingContext = /*#__PURE__*/ function() {
|
|
3390
4120
|
function SimpleLoadingContext() {
|
|
3391
4121
|
var loading = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
@@ -3398,19 +4128,25 @@ function _object_spread_props$3(target, source) {
|
|
|
3398
4128
|
}
|
|
3399
4129
|
_create_class$4(SimpleLoadingContext, [
|
|
3400
4130
|
{
|
|
3401
|
-
|
|
4131
|
+
/**
|
|
4132
|
+
* Completes the internal subject, ending the stream.
|
|
4133
|
+
*/ key: "destroy",
|
|
3402
4134
|
value: function destroy() {
|
|
3403
4135
|
this._subject.complete();
|
|
3404
4136
|
}
|
|
3405
4137
|
},
|
|
3406
4138
|
{
|
|
3407
|
-
|
|
4139
|
+
/**
|
|
4140
|
+
* Whether the current state has a non-null error.
|
|
4141
|
+
*/ key: "hasError",
|
|
3408
4142
|
value: function hasError() {
|
|
3409
4143
|
return isLoadingStateWithError(this._subject.value);
|
|
3410
4144
|
}
|
|
3411
4145
|
},
|
|
3412
4146
|
{
|
|
3413
|
-
|
|
4147
|
+
/**
|
|
4148
|
+
* Clears the current error while preserving other state.
|
|
4149
|
+
*/ key: "clearError",
|
|
3414
4150
|
value: function clearError() {
|
|
3415
4151
|
this._subject.next(_object_spread_props$3(_object_spread$3({}, this._subject.value), {
|
|
3416
4152
|
error: undefined
|
|
@@ -3418,13 +4154,19 @@ function _object_spread_props$3(target, source) {
|
|
|
3418
4154
|
}
|
|
3419
4155
|
},
|
|
3420
4156
|
{
|
|
3421
|
-
|
|
4157
|
+
/**
|
|
4158
|
+
* Convenience method to mark loading as complete (sets loading to false).
|
|
4159
|
+
*/ key: "setSuccess",
|
|
3422
4160
|
value: function setSuccess() {
|
|
3423
4161
|
this.setLoading(false);
|
|
3424
4162
|
}
|
|
3425
4163
|
},
|
|
3426
4164
|
{
|
|
3427
|
-
|
|
4165
|
+
/**
|
|
4166
|
+
* Sets the loading flag and clears any existing error.
|
|
4167
|
+
*
|
|
4168
|
+
* @param loading - whether loading is in progress (defaults to true)
|
|
4169
|
+
*/ key: "setLoading",
|
|
3428
4170
|
value: function setLoading() {
|
|
3429
4171
|
var loading = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
3430
4172
|
// clears the current error
|
|
@@ -3434,7 +4176,12 @@ function _object_spread_props$3(target, source) {
|
|
|
3434
4176
|
}
|
|
3435
4177
|
},
|
|
3436
4178
|
{
|
|
3437
|
-
|
|
4179
|
+
/**
|
|
4180
|
+
* Sets an error state with an optional loading flag.
|
|
4181
|
+
*
|
|
4182
|
+
* @param error - the error to set
|
|
4183
|
+
* @param loading - whether loading is still in progress (defaults to false)
|
|
4184
|
+
*/ key: "setError",
|
|
3438
4185
|
value: function setError(error) {
|
|
3439
4186
|
var loading = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
3440
4187
|
this._subject.next({
|
|
@@ -3534,7 +4281,31 @@ function _is_native_reflect_construct() {
|
|
|
3534
4281
|
})();
|
|
3535
4282
|
}
|
|
3536
4283
|
/**
|
|
3537
|
-
*
|
|
4284
|
+
* A {@link SimpleLoadingContext} that determines loading completion by checking whether
|
|
4285
|
+
* all values returned by a check function are defined.
|
|
4286
|
+
*
|
|
4287
|
+
* Useful when loading depends on multiple values arriving asynchronously — call {@link check}
|
|
4288
|
+
* to re-evaluate whether all required values are present.
|
|
4289
|
+
*
|
|
4290
|
+
* @example
|
|
4291
|
+
* ```ts
|
|
4292
|
+
* let valueA: string | undefined;
|
|
4293
|
+
* let valueB: string | undefined;
|
|
4294
|
+
*
|
|
4295
|
+
* const context = new ValuesLoadingContext({
|
|
4296
|
+
* checkDone: () => [valueA, valueB]
|
|
4297
|
+
* });
|
|
4298
|
+
* // context.stream$ emits { loading: true }
|
|
4299
|
+
*
|
|
4300
|
+
* valueA = 'hello';
|
|
4301
|
+
* context.check(); // still loading (valueB is undefined)
|
|
4302
|
+
*
|
|
4303
|
+
* valueB = 'world';
|
|
4304
|
+
* context.check(); // loading complete (both defined)
|
|
4305
|
+
* // context.stream$ emits { loading: false }
|
|
4306
|
+
*
|
|
4307
|
+
* context.destroy();
|
|
4308
|
+
* ```
|
|
3538
4309
|
*/ var ValuesLoadingContext = /*#__PURE__*/ function(SimpleLoadingContext) {
|
|
3539
4310
|
_inherits(ValuesLoadingContext, SimpleLoadingContext);
|
|
3540
4311
|
function ValuesLoadingContext() {
|
|
@@ -3550,9 +4321,12 @@ function _is_native_reflect_construct() {
|
|
|
3550
4321
|
_create_class$3(ValuesLoadingContext, [
|
|
3551
4322
|
{
|
|
3552
4323
|
/**
|
|
3553
|
-
*
|
|
4324
|
+
* Re-evaluates the check function to determine whether all values are loaded.
|
|
3554
4325
|
*
|
|
3555
|
-
*
|
|
4326
|
+
* Sets loading to `false` when every element in the check array is defined.
|
|
4327
|
+
* Does nothing if the context currently has an error.
|
|
4328
|
+
*
|
|
4329
|
+
* @throws {Error} When no check function was provided in the constructor configuration.
|
|
3556
4330
|
*/ key: "check",
|
|
3557
4331
|
value: function check() {
|
|
3558
4332
|
if (!this.hasError()) {
|
|
@@ -3803,13 +4577,13 @@ function itemAccumulator(itemIteration, inputMapItem) {
|
|
|
3803
4577
|
return result;
|
|
3804
4578
|
}
|
|
3805
4579
|
/**
|
|
3806
|
-
* Automatically
|
|
4580
|
+
* Automatically pages through an accumulator's iteration until the desired number of results
|
|
4581
|
+
* is reached or no more pages are available.
|
|
3807
4582
|
*
|
|
3808
|
-
*
|
|
4583
|
+
* @param config - configuration specifying the accumulator, result limit, and counting function
|
|
4584
|
+
* @returns promise resolving to the final page number and total results count
|
|
3809
4585
|
*
|
|
3810
|
-
* @
|
|
3811
|
-
* @param maxResultsLimit
|
|
3812
|
-
* @returns
|
|
4586
|
+
* @throws Rejects if the iteration encounters an error during loading
|
|
3813
4587
|
*/ function itemAccumulatorNextPageUntilResultsCount(config) {
|
|
3814
4588
|
var accumulator = config.accumulator, maxResultsLimit = config.maxResultsLimit, countResults = config.countResultsFunction;
|
|
3815
4589
|
var getMaxResultsLimit = asGetter(maxResultsLimit);
|
|
@@ -3960,10 +4734,13 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
3960
4734
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
3961
4735
|
}
|
|
3962
4736
|
/**
|
|
3963
|
-
*
|
|
4737
|
+
* Flattens paginated array results from an {@link ItemAccumulator} into a single growing array.
|
|
3964
4738
|
*
|
|
3965
|
-
*
|
|
3966
|
-
*
|
|
4739
|
+
* Designed for accumulators where each page returns an array of items. Concatenates all
|
|
4740
|
+
* page results into one flat array that grows as new pages are loaded.
|
|
4741
|
+
*
|
|
4742
|
+
* @param accumulator - accumulator whose page results are arrays to flatten
|
|
4743
|
+
* @returns observable emitting the flattened array of all accumulated items
|
|
3967
4744
|
*/ function flattenAccumulatorResultItemArray(accumulator) {
|
|
3968
4745
|
return accumulator.currentAllItemPairs$.pipe(scanBuildArray(function(allItems) {
|
|
3969
4746
|
var pairs = allItems;
|
|
@@ -3984,7 +4761,14 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
3984
4761
|
}));
|
|
3985
4762
|
}
|
|
3986
4763
|
/**
|
|
3987
|
-
*
|
|
4764
|
+
* Combines a page accumulator's flattened array results with its current loading state
|
|
4765
|
+
* into a single {@link PageListLoadingState} observable.
|
|
4766
|
+
*
|
|
4767
|
+
* The loading state reflects whether a page is currently being fetched, while the value
|
|
4768
|
+
* always contains the full flattened array of all items loaded so far.
|
|
4769
|
+
*
|
|
4770
|
+
* @param accumulator - page accumulator whose results are arrays to flatten
|
|
4771
|
+
* @returns observable of the combined loading state with all accumulated items
|
|
3988
4772
|
*/ function accumulatorFlattenPageListLoadingState(accumulator) {
|
|
3989
4773
|
return combineLatest([
|
|
3990
4774
|
accumulator.itemIteration.currentState$,
|
|
@@ -4000,7 +4784,14 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
4000
4784
|
}), shareReplay(1));
|
|
4001
4785
|
}
|
|
4002
4786
|
/**
|
|
4003
|
-
*
|
|
4787
|
+
* Combines a page accumulator's collected items with its current loading state
|
|
4788
|
+
* into a single {@link PageListLoadingState} observable.
|
|
4789
|
+
*
|
|
4790
|
+
* Unlike {@link accumulatorFlattenPageListLoadingState}, this does not flatten arrays —
|
|
4791
|
+
* each accumulated value is included as-is.
|
|
4792
|
+
*
|
|
4793
|
+
* @param accumulator - page accumulator to observe
|
|
4794
|
+
* @returns observable of the combined loading state with all accumulated items
|
|
4004
4795
|
*/ function accumulatorCurrentPageListLoadingState(accumulator) {
|
|
4005
4796
|
return combineLatest([
|
|
4006
4797
|
accumulator.itemIteration.currentState$,
|
|
@@ -4016,20 +4807,23 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
4016
4807
|
}), shareReplay(1));
|
|
4017
4808
|
}
|
|
4018
4809
|
/**
|
|
4019
|
-
* Returns the latest loaded page number from the input
|
|
4810
|
+
* Returns the latest loaded page number from the input accumulator's underlying iteration.
|
|
4020
4811
|
*
|
|
4021
|
-
* @param pageItemAccumulator
|
|
4022
|
-
* @returns
|
|
4812
|
+
* @param pageItemAccumulator - accumulator to observe the current page from
|
|
4813
|
+
* @returns observable emitting the most recently loaded page number
|
|
4023
4814
|
*/ function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
|
|
4024
4815
|
return pageItemAccumulator.itemIteration.latestLoadedPage$;
|
|
4025
4816
|
}
|
|
4026
4817
|
|
|
4027
4818
|
/**
|
|
4028
|
-
* Creates a
|
|
4819
|
+
* Creates a {@link MappedItemIterationInstance} that wraps an existing iteration and transforms
|
|
4820
|
+
* its loading state values through the provided mapping configuration.
|
|
4029
4821
|
*
|
|
4030
|
-
*
|
|
4031
|
-
*
|
|
4032
|
-
* @
|
|
4822
|
+
* Control flow (next, hasNext, canLoadMore) is delegated directly to the underlying iteration.
|
|
4823
|
+
*
|
|
4824
|
+
* @param itemIterator - the source iteration to wrap
|
|
4825
|
+
* @param config - mapping configuration for transforming loading state values
|
|
4826
|
+
* @returns mapped iteration instance with transformed state observables
|
|
4033
4827
|
*/ function mapItemIteration(itemIterator, config) {
|
|
4034
4828
|
var hasNext$ = itemIterator.hasNext$;
|
|
4035
4829
|
var canLoadMore$ = itemIterator.canLoadMore$;
|
|
@@ -4112,11 +4906,13 @@ function _object_spread_props$2(target, source) {
|
|
|
4112
4906
|
return target;
|
|
4113
4907
|
}
|
|
4114
4908
|
/**
|
|
4115
|
-
* Creates a
|
|
4909
|
+
* Creates a {@link MappedPageItemIterationInstance} that wraps a {@link PageItemIteration}
|
|
4910
|
+
* and transforms its loading state values while preserving page-level operations
|
|
4911
|
+
* (nextPage, page load limits, latestLoadedPage).
|
|
4116
4912
|
*
|
|
4117
|
-
* @param itemIteration
|
|
4118
|
-
* @param config
|
|
4119
|
-
* @returns
|
|
4913
|
+
* @param itemIteration - the source page iteration to wrap
|
|
4914
|
+
* @param config - mapping configuration for transforming loading state values
|
|
4915
|
+
* @returns mapped page iteration instance
|
|
4120
4916
|
*/ function mappedPageItemIteration(itemIteration, config) {
|
|
4121
4917
|
function nextPage(request) {
|
|
4122
4918
|
return itemIteration.nextPage(request);
|
|
@@ -4244,12 +5040,24 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
4244
5040
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4245
5041
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
4246
5042
|
}
|
|
4247
|
-
// MARK: Iterator
|
|
4248
5043
|
/**
|
|
4249
|
-
* Default number of pages that can be loaded.
|
|
5044
|
+
* Default maximum number of pages that can be loaded by an {@link ItemPageIterator}.
|
|
4250
5045
|
*/ var DEFAULT_ITEM_PAGE_ITERATOR_MAX = 100;
|
|
4251
5046
|
/**
|
|
4252
|
-
*
|
|
5047
|
+
* Factory for creating paginated iteration instances from a delegate and configuration.
|
|
5048
|
+
*
|
|
5049
|
+
* The iterator itself holds the delegate (data-loading logic) and optional global page limits.
|
|
5050
|
+
* Call {@link instance} to create a new iteration session with a specific configuration.
|
|
5051
|
+
*
|
|
5052
|
+
* @example
|
|
5053
|
+
* ```ts
|
|
5054
|
+
* const iterator = new ItemPageIterator({
|
|
5055
|
+
* loadItemsForPage: (request) => fetchPage(request.page)
|
|
5056
|
+
* });
|
|
5057
|
+
*
|
|
5058
|
+
* const instance = iterator.instance({ filter: 'active', maxPageLoadLimit: 10 });
|
|
5059
|
+
* instance.next(); // loads first page
|
|
5060
|
+
* ```
|
|
4253
5061
|
*/ var ItemPageIterator = /*#__PURE__*/ function() {
|
|
4254
5062
|
function ItemPageIterator(delegate) {
|
|
4255
5063
|
_class_call_check$2(this, ItemPageIterator);
|
|
@@ -4287,10 +5095,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
4287
5095
|
},
|
|
4288
5096
|
{
|
|
4289
5097
|
/**
|
|
4290
|
-
* Creates a new instance
|
|
5098
|
+
* Creates a new iteration instance with the given configuration.
|
|
4291
5099
|
*
|
|
4292
|
-
* @param config
|
|
4293
|
-
* @returns
|
|
5100
|
+
* @param config - filter and page limit configuration for this iteration session
|
|
5101
|
+
* @returns new iteration instance ready to begin loading pages
|
|
4294
5102
|
*/ key: "instance",
|
|
4295
5103
|
value: function instance(config) {
|
|
4296
5104
|
return new ItemPageIterationInstance(this, config);
|
|
@@ -4300,7 +5108,11 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
4300
5108
|
return ItemPageIterator;
|
|
4301
5109
|
}();
|
|
4302
5110
|
/**
|
|
4303
|
-
*
|
|
5111
|
+
* Active iteration session created by an {@link ItemPageIterator}.
|
|
5112
|
+
*
|
|
5113
|
+
* Manages the lifecycle of paginated loading: triggering page loads via {@link next},
|
|
5114
|
+
* tracking loading/success/error states, and exposing all results as reactive observables.
|
|
5115
|
+
* Implements {@link PageItemIteration} for use with accumulators and other iteration utilities.
|
|
4304
5116
|
*/ var ItemPageIterationInstance = /*#__PURE__*/ function() {
|
|
4305
5117
|
function ItemPageIterationInstance(iterator, config) {
|
|
4306
5118
|
var _this = this;
|
|
@@ -4584,15 +5396,16 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
4584
5396
|
]);
|
|
4585
5397
|
return ItemPageIterationInstance;
|
|
4586
5398
|
}();
|
|
4587
|
-
// MARK: Utility
|
|
4588
5399
|
/**
|
|
4589
|
-
*
|
|
5400
|
+
* Determines whether an {@link ItemPageIteratorResult} represents the end of iteration.
|
|
4590
5401
|
*
|
|
4591
|
-
*
|
|
4592
|
-
* - end is
|
|
5402
|
+
* End is detected when:
|
|
5403
|
+
* - `end` is explicitly `true`
|
|
5404
|
+
* - `end` is not explicitly `false` and the result value is empty/null (via `hasValueOrNotEmpty`)
|
|
5405
|
+
* - Error results are never considered the end
|
|
4593
5406
|
*
|
|
4594
|
-
* @param result
|
|
4595
|
-
* @returns
|
|
5407
|
+
* @param result - the page result to check
|
|
5408
|
+
* @returns `true` if this result indicates no more pages are available
|
|
4596
5409
|
*/ function isItemPageIteratorResultEndResult(result) {
|
|
4597
5410
|
if (result.error != null) {
|
|
4598
5411
|
return false;
|
|
@@ -4693,9 +5506,28 @@ function _type_of(obj) {
|
|
|
4693
5506
|
"@swc/helpers - typeof";
|
|
4694
5507
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4695
5508
|
}
|
|
4696
|
-
var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
4697
5509
|
/**
|
|
4698
|
-
*
|
|
5510
|
+
* Default lock key used by {@link LockSet.lockForTime} when no custom key is provided.
|
|
5511
|
+
*/ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
5512
|
+
/**
|
|
5513
|
+
* Subscribes to the next unlock event of a {@link LockSet}, invoking the callback when it becomes unlocked or the timeout expires.
|
|
5514
|
+
*
|
|
5515
|
+
* Useful for deferring an action until all locks are released, with a safety timeout to avoid waiting indefinitely.
|
|
5516
|
+
*
|
|
5517
|
+
* @param config - configuration specifying the lock set, callback, timeout, and optional delay
|
|
5518
|
+
* @returns subscription that can be unsubscribed to cancel the wait
|
|
5519
|
+
*
|
|
5520
|
+
* @example
|
|
5521
|
+
* ```ts
|
|
5522
|
+
* const lockSet = new LockSet();
|
|
5523
|
+
* lockSet.addLock('busy', of(true));
|
|
5524
|
+
*
|
|
5525
|
+
* const sub = onLockSetNextUnlock({
|
|
5526
|
+
* lockSet,
|
|
5527
|
+
* fn: (unlocked) => console.log('Unlocked:', unlocked),
|
|
5528
|
+
* timeout: 5000
|
|
5529
|
+
* });
|
|
5530
|
+
* ```
|
|
4699
5531
|
*/ function onLockSetNextUnlock(param) {
|
|
4700
5532
|
var lockSet = param.lockSet, fn = param.fn, inputTimeout = param.timeout, delayTime = param.delayTime;
|
|
4701
5533
|
var timeoutTime = inputTimeout !== null && inputTimeout !== void 0 ? inputTimeout : MS_IN_SECOND * 50;
|
|
@@ -4714,9 +5546,29 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4714
5546
|
});
|
|
4715
5547
|
}
|
|
4716
5548
|
/**
|
|
4717
|
-
*
|
|
5549
|
+
* Observable-based locking mechanism that prevents actions until all registered locks are released.
|
|
5550
|
+
*
|
|
5551
|
+
* Each lock is identified by a {@link LockKey} and backed by an `Observable<boolean>`. The lock set
|
|
5552
|
+
* is considered locked when any registered observable emits `true`. Empty or completed observables
|
|
5553
|
+
* are treated as unlocked, so locks do not need to be explicitly removed.
|
|
5554
|
+
*
|
|
5555
|
+
* Supports hierarchical locking via parent/child relationships between lock sets.
|
|
5556
|
+
*
|
|
5557
|
+
* @example
|
|
5558
|
+
* ```ts
|
|
5559
|
+
* const lockSet = new LockSet();
|
|
4718
5560
|
*
|
|
4719
|
-
*
|
|
5561
|
+
* // Add a lock that is currently active
|
|
5562
|
+
* const removeLock = lockSet.addLock('saving', of(true));
|
|
5563
|
+
*
|
|
5564
|
+
* // Check locked state
|
|
5565
|
+
* lockSet.isLocked$.subscribe(locked => console.log('Locked:', locked));
|
|
5566
|
+
* // Output: Locked: true
|
|
5567
|
+
*
|
|
5568
|
+
* // Remove the lock
|
|
5569
|
+
* removeLock();
|
|
5570
|
+
* // Output: Locked: false
|
|
5571
|
+
* ```
|
|
4720
5572
|
*/ var LockSet = /*#__PURE__*/ function() {
|
|
4721
5573
|
function LockSet() {
|
|
4722
5574
|
_class_call_check$1(this, LockSet);
|
|
@@ -4724,16 +5576,23 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4724
5576
|
_define_property$1(this, "_onDestroy", new Subject());
|
|
4725
5577
|
_define_property$1(this, "_locks", new BehaviorSubject(new Map()));
|
|
4726
5578
|
_define_property$1(this, "_parentSub", new SubscriptionObject());
|
|
4727
|
-
_define_property$1(this, "locks$", this._locks.asObservable());
|
|
4728
5579
|
/**
|
|
4729
|
-
*
|
|
5580
|
+
* Observable of the current lock map, emitting whenever locks are added or removed.
|
|
5581
|
+
*/ _define_property$1(this, "locks$", this._locks.asObservable());
|
|
5582
|
+
/**
|
|
5583
|
+
* Observable that emits `true` when any registered lock observable is emitting `true`.
|
|
5584
|
+
* Emits `false` when all locks are released or the map is empty.
|
|
4730
5585
|
*/ _define_property$1(this, "isLocked$", this.locks$.pipe(switchMap(combineLatestFromMapValuesObsFn(function(x) {
|
|
4731
5586
|
return x;
|
|
4732
5587
|
})), map(reduceBooleansWithOrFn(false)), shareReplay(1)));
|
|
4733
|
-
|
|
5588
|
+
/**
|
|
5589
|
+
* Observable that emits `true` when no locks are active. Inverse of {@link isLocked$}.
|
|
5590
|
+
*/ _define_property$1(this, "isUnlocked$", this.isLocked$.pipe(map(function(x) {
|
|
4734
5591
|
return !x;
|
|
4735
5592
|
})));
|
|
4736
|
-
|
|
5593
|
+
/**
|
|
5594
|
+
* Observable that emits when this lock set is destroyed. Useful for cleanup coordination.
|
|
5595
|
+
*/ _define_property$1(this, "onDestroy$", this._onDestroy.pipe(shareReplay(1)));
|
|
4737
5596
|
}
|
|
4738
5597
|
_create_class$1(LockSet, [
|
|
4739
5598
|
{
|
|
@@ -4771,19 +5630,44 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4771
5630
|
}
|
|
4772
5631
|
},
|
|
4773
5632
|
{
|
|
4774
|
-
|
|
5633
|
+
/**
|
|
5634
|
+
* Locks for a specified number of seconds using the default time lock key.
|
|
5635
|
+
*
|
|
5636
|
+
* @param seconds - duration in seconds
|
|
5637
|
+
*/ key: "lockForSeconds",
|
|
4775
5638
|
value: function lockForSeconds(seconds) {
|
|
4776
5639
|
this.lockForTime(seconds * 1000);
|
|
4777
5640
|
}
|
|
4778
5641
|
},
|
|
4779
5642
|
{
|
|
4780
|
-
|
|
5643
|
+
/**
|
|
5644
|
+
* Locks for a specified duration in milliseconds, automatically unlocking when the time elapses.
|
|
5645
|
+
*
|
|
5646
|
+
* @param milliseconds - lock duration
|
|
5647
|
+
* @param key - optional lock key, defaults to {@link DEFAULT_LOCK_SET_TIME_LOCK_KEY}
|
|
5648
|
+
*/ key: "lockForTime",
|
|
4781
5649
|
value: function lockForTime(milliseconds, key) {
|
|
4782
5650
|
this.addLock(key !== null && key !== void 0 ? key : DEFAULT_LOCK_SET_TIME_LOCK_KEY, of(false).pipe(delay(milliseconds), startWith(true)));
|
|
4783
5651
|
}
|
|
4784
5652
|
},
|
|
4785
5653
|
{
|
|
4786
|
-
|
|
5654
|
+
/**
|
|
5655
|
+
* Registers a lock observable under the given key. The lock is considered active when
|
|
5656
|
+
* the observable emits `true`. Empty observables are treated as unlocked.
|
|
5657
|
+
*
|
|
5658
|
+
* @param key - identifier for this lock
|
|
5659
|
+
* @param obs - observable that emits the lock state
|
|
5660
|
+
* @returns function that removes this specific lock when called
|
|
5661
|
+
*
|
|
5662
|
+
* @example
|
|
5663
|
+
* ```ts
|
|
5664
|
+
* const lockSet = new LockSet();
|
|
5665
|
+
* const remove = lockSet.addLock('saving', of(true));
|
|
5666
|
+
*
|
|
5667
|
+
* // Later, release the lock
|
|
5668
|
+
* remove();
|
|
5669
|
+
* ```
|
|
5670
|
+
*/ key: "addLock",
|
|
4787
5671
|
value: function addLock(key, obs) {
|
|
4788
5672
|
var _this = this;
|
|
4789
5673
|
obs = obs.pipe(defaultIfEmpty(false) // empty observables count as unlocked.
|
|
@@ -4806,7 +5690,11 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4806
5690
|
}
|
|
4807
5691
|
},
|
|
4808
5692
|
{
|
|
4809
|
-
|
|
5693
|
+
/**
|
|
5694
|
+
* Removes the lock registered under the given key, if it exists.
|
|
5695
|
+
*
|
|
5696
|
+
* @param key - identifier of the lock to remove
|
|
5697
|
+
*/ key: "removeLock",
|
|
4810
5698
|
value: function removeLock(key) {
|
|
4811
5699
|
if (this._locks.value.delete(key)) {
|
|
4812
5700
|
this._locks.next(this.locks);
|
|
@@ -4814,7 +5702,13 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4814
5702
|
}
|
|
4815
5703
|
},
|
|
4816
5704
|
{
|
|
4817
|
-
|
|
5705
|
+
/**
|
|
5706
|
+
* Registers a callback for the next time this lock set becomes unlocked.
|
|
5707
|
+
*
|
|
5708
|
+
* @param config - callback function or configuration object
|
|
5709
|
+
* @param delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
5710
|
+
* @returns subscription that can be unsubscribed to cancel the wait
|
|
5711
|
+
*/ key: "onNextUnlock",
|
|
4818
5712
|
value: function onNextUnlock(config, delayTime) {
|
|
4819
5713
|
return onLockSetNextUnlock(_object_spread({
|
|
4820
5714
|
lockSet: this,
|
|
@@ -4825,7 +5719,12 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4825
5719
|
}
|
|
4826
5720
|
},
|
|
4827
5721
|
{
|
|
4828
|
-
|
|
5722
|
+
/**
|
|
5723
|
+
* Establishes a parent-child relationship where this lock set's locked state is propagated
|
|
5724
|
+
* to the parent. When this lock set is locked, the parent will also reflect a locked state.
|
|
5725
|
+
*
|
|
5726
|
+
* @param parent - parent lock set or observable of one; pass `undefined` to detach
|
|
5727
|
+
*/ key: "setParentLockSet",
|
|
4829
5728
|
value: function setParentLockSet(parent) {
|
|
4830
5729
|
var _this = this;
|
|
4831
5730
|
this._parentSub.subscription = preventComplete(asObservable(parent)).pipe(map(function(parentLockSet) {
|
|
@@ -4841,7 +5740,11 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4841
5740
|
},
|
|
4842
5741
|
{
|
|
4843
5742
|
/**
|
|
4844
|
-
*
|
|
5743
|
+
* Registers a child lock set so its locked state propagates upward to this lock set.
|
|
5744
|
+
*
|
|
5745
|
+
* @param lockSet - child lock set to monitor
|
|
5746
|
+
* @param key - optional lock key, auto-generated if not provided
|
|
5747
|
+
* @returns function that removes the child lock relationship when called
|
|
4845
5748
|
*/ key: "addChildLockSet",
|
|
4846
5749
|
value: function addChildLockSet(lockSet) {
|
|
4847
5750
|
var key = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "".concat(LockSet.LOCK_SET_CHILD_INDEX_STEPPER++);
|
|
@@ -4856,7 +5759,15 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4856
5759
|
}
|
|
4857
5760
|
},
|
|
4858
5761
|
{
|
|
4859
|
-
|
|
5762
|
+
/**
|
|
5763
|
+
* Schedules this lock set for destruction when it next becomes unlocked.
|
|
5764
|
+
*
|
|
5765
|
+
* After the unlock event (or timeout), the optional callback is invoked and then
|
|
5766
|
+
* {@link destroy} is called after a short delay.
|
|
5767
|
+
*
|
|
5768
|
+
* @param config - optional callback or configuration for the unlock wait
|
|
5769
|
+
* @param delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
5770
|
+
*/ key: "destroyOnNextUnlock",
|
|
4860
5771
|
value: function destroyOnNextUnlock(config, delayTime) {
|
|
4861
5772
|
var _this = this;
|
|
4862
5773
|
var fn;
|
|
@@ -4881,7 +5792,9 @@ var DEFAULT_LOCK_SET_TIME_LOCK_KEY = 'timelock';
|
|
|
4881
5792
|
}
|
|
4882
5793
|
},
|
|
4883
5794
|
{
|
|
4884
|
-
|
|
5795
|
+
/**
|
|
5796
|
+
* Completes all internal subjects, unsubscribes from the parent lock set, and marks this lock set as destroyed.
|
|
5797
|
+
*/ key: "destroy",
|
|
4885
5798
|
value: function destroy() {
|
|
4886
5799
|
this._isDestroyed = true;
|
|
4887
5800
|
this._locks.complete();
|
|
@@ -4928,7 +5841,21 @@ function _define_property(obj, key, value) {
|
|
|
4928
5841
|
return obj;
|
|
4929
5842
|
}
|
|
4930
5843
|
/**
|
|
4931
|
-
*
|
|
5844
|
+
* Tracks the lifecycle of an asynchronous work unit from start through completion (success or error).
|
|
5845
|
+
*
|
|
5846
|
+
* Exposes reactive streams for monitoring progress (`hasStarted$`, `isComplete$`, `loadingState$`)
|
|
5847
|
+
* and provides methods for starting work via observables, promises, or direct state management.
|
|
5848
|
+
*
|
|
5849
|
+
* @example
|
|
5850
|
+
* ```ts
|
|
5851
|
+
* const instance = new WorkInstance(inputValue, {
|
|
5852
|
+
* startWorking: () => console.log('started'),
|
|
5853
|
+
* success: (result) => console.log('done:', result),
|
|
5854
|
+
* reject: (err) => console.error('failed:', err)
|
|
5855
|
+
* });
|
|
5856
|
+
*
|
|
5857
|
+
* instance.startWorkingWithObservable(of('result'));
|
|
5858
|
+
* ```
|
|
4932
5859
|
*/ var WorkInstance = /*#__PURE__*/ function() {
|
|
4933
5860
|
function WorkInstance(value, delegate) {
|
|
4934
5861
|
var _this = this;
|
|
@@ -5162,7 +6089,24 @@ function _define_property(obj, key, value) {
|
|
|
5162
6089
|
();
|
|
5163
6090
|
|
|
5164
6091
|
/**
|
|
5165
|
-
* Creates a
|
|
6092
|
+
* Creates a {@link WorkFactory} that executes the configured work function with a {@link WorkInstance} handler.
|
|
6093
|
+
*
|
|
6094
|
+
* If the work function returns an observable, it is automatically subscribed to. If it uses
|
|
6095
|
+
* the handler directly, the observable return is ignored.
|
|
6096
|
+
*
|
|
6097
|
+
* @example
|
|
6098
|
+
* ```ts
|
|
6099
|
+
* const factory = workFactory({
|
|
6100
|
+
* work: (value: number) => of(`result: ${value}`),
|
|
6101
|
+
* delegate: { startWorking: () => {}, success: () => {}, reject: () => {} }
|
|
6102
|
+
* });
|
|
6103
|
+
*
|
|
6104
|
+
* const instance = factory(42);
|
|
6105
|
+
* // instance tracks the work lifecycle
|
|
6106
|
+
* ```
|
|
6107
|
+
*
|
|
6108
|
+
* @param config - work function and delegate configuration
|
|
6109
|
+
* @returns a factory function that creates WorkInstance for each input
|
|
5166
6110
|
*/ function workFactory(param) {
|
|
5167
6111
|
var work = param.work, delegate = param.delegate;
|
|
5168
6112
|
return function(value) {
|
|
@@ -5187,7 +6131,11 @@ function _define_property(obj, key, value) {
|
|
|
5187
6131
|
};
|
|
5188
6132
|
}
|
|
5189
6133
|
/**
|
|
5190
|
-
* Creates a WorkFactory
|
|
6134
|
+
* Creates a {@link WorkFactory} that generates a new {@link WorkFactoryConfig} for each input,
|
|
6135
|
+
* enabling dynamic work and delegate selection per invocation.
|
|
6136
|
+
*
|
|
6137
|
+
* @param configFactory - factory that produces work configuration from the input value
|
|
6138
|
+
* @returns a work factory with per-invocation configuration
|
|
5191
6139
|
*/ function workFactoryForConfigFactory(configFactory) {
|
|
5192
6140
|
return function(value) {
|
|
5193
6141
|
var config = configFactory(value);
|