@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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,55 +1,70 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Abstract base class for providing reactive filter state.
|
|
4
|
+
*
|
|
5
|
+
* Implementations expose a `filter$` observable that emits the current filter value,
|
|
6
|
+
* and optionally support initialization from an external observable.
|
|
4
7
|
*/
|
|
5
8
|
export declare abstract class FilterSource<F = unknown> {
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
10
|
+
* Observable of the current filter value.
|
|
8
11
|
*/
|
|
9
12
|
abstract readonly filter$: Observable<F>;
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* Optionally initializes this filter source from an external observable.
|
|
12
15
|
*
|
|
13
|
-
*
|
|
16
|
+
* Allows setting the initial/default filter value from an upstream source,
|
|
17
|
+
* which is useful when composing filters hierarchically.
|
|
14
18
|
*/
|
|
15
19
|
abstract initWithFilter?(filterObs: Observable<F>): void;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* String identifier used to reference a named filter preset configuration.
|
|
19
23
|
*/
|
|
20
24
|
export type FilterPresetString = string;
|
|
21
25
|
/**
|
|
22
|
-
*
|
|
26
|
+
* Object that contains a {@link FilterPresetString} reference.
|
|
23
27
|
*
|
|
24
|
-
* When a preset value is present, it may either be used as the sole filter
|
|
28
|
+
* When a preset value is present, it may either be used as the sole filter configuration
|
|
29
|
+
* or act as a base that is overridden by other filter values.
|
|
25
30
|
*/
|
|
26
31
|
export interface FilterPresetStringRef<P extends string = string> {
|
|
27
32
|
/**
|
|
28
|
-
* Preset key.
|
|
33
|
+
* Preset key identifying a named filter configuration.
|
|
29
34
|
*/
|
|
30
35
|
preset: P;
|
|
31
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Filter type that optionally includes a preset reference.
|
|
39
|
+
*/
|
|
32
40
|
export type FilterWithPreset<P extends string = string> = Partial<FilterPresetStringRef<P>>;
|
|
41
|
+
/**
|
|
42
|
+
* Makes the preset field optional on a filter that normally includes one.
|
|
43
|
+
*/
|
|
33
44
|
export type FilterWithPresetOptional<F extends FilterWithPreset<P>, P extends string = string> = Partial<Pick<F, 'preset'>> & Omit<F, 'preset'>;
|
|
34
45
|
/**
|
|
35
|
-
*
|
|
46
|
+
* Extracts only the preset field from a filter type, discarding all other filter properties.
|
|
36
47
|
*/
|
|
37
48
|
export type FilterOnlyWithPresetString<F extends FilterWithPreset<P>, P extends string = string> = Pick<F, 'preset'>;
|
|
38
49
|
/**
|
|
39
|
-
*
|
|
50
|
+
* Filter type with the preset field removed, retaining only the concrete filter properties.
|
|
40
51
|
*/
|
|
41
52
|
export type FilterWithoutPresetString<F extends FilterWithPreset<P>, P extends string = string> = Omit<F, 'preset'>;
|
|
42
53
|
/**
|
|
43
|
-
* A FilterSource
|
|
54
|
+
* A {@link FilterSource} whose filter type includes an optional preset reference.
|
|
55
|
+
*
|
|
56
|
+
* Useful for filter UIs that support both preset configurations and custom filter values.
|
|
44
57
|
*/
|
|
45
58
|
export declare abstract class PresetFilterSource<F extends FilterWithPreset<P>, P extends string = string> extends FilterSource<F> {
|
|
46
59
|
}
|
|
47
60
|
/**
|
|
48
|
-
*
|
|
61
|
+
* Abstract connector that wires a {@link FilterSource} into a consuming component.
|
|
62
|
+
*
|
|
63
|
+
* Implementations define how to subscribe to a filter source and apply its values.
|
|
49
64
|
*/
|
|
50
65
|
export declare abstract class FilterSourceConnector<F = unknown> {
|
|
51
66
|
/**
|
|
52
|
-
*
|
|
67
|
+
* Connects with the input filter source to begin receiving filter updates.
|
|
53
68
|
*/
|
|
54
69
|
abstract connectWithSource(filterSource: FilterSource<F>): void;
|
|
55
70
|
}
|
|
@@ -3,29 +3,96 @@ import { type Observable } from 'rxjs';
|
|
|
3
3
|
import { type FilterSource, type FilterSourceConnector } from './filter';
|
|
4
4
|
import { type Destroyable, type Maybe } from '@dereekb/util';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* String key used to identify a specific filter entry within a {@link FilterMap}.
|
|
7
7
|
*/
|
|
8
8
|
export type FilterMapKey = string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Manages a collection of reactive filters keyed by string identifiers.
|
|
11
|
+
*
|
|
12
|
+
* Multiple filter observables can be registered under the same key and their emissions are merged.
|
|
13
|
+
* Supports default filters that are used when no explicit filter is set.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const filterMap = new FilterMap<{ active: boolean }>();
|
|
18
|
+
*
|
|
19
|
+
* // Register a filter observable under a key
|
|
20
|
+
* filterMap.addFilterObs('users', of({ active: true }));
|
|
21
|
+
*
|
|
22
|
+
* // Subscribe to the filter for that key
|
|
23
|
+
* filterMap.filterForKey('users').subscribe(f => console.log(f));
|
|
24
|
+
* // Output: { active: true }
|
|
25
|
+
* ```
|
|
11
26
|
*/
|
|
12
27
|
export declare class FilterMap<F> implements Destroyable {
|
|
13
28
|
private readonly _map;
|
|
29
|
+
/**
|
|
30
|
+
* Returns an observable of the filter value for the given key.
|
|
31
|
+
*
|
|
32
|
+
* Waits until a filter entry exists for the key, then switches to its filter stream.
|
|
33
|
+
*
|
|
34
|
+
* @param key - filter map key to observe
|
|
35
|
+
* @returns observable that emits the current filter value for the key
|
|
36
|
+
*/
|
|
14
37
|
filterForKey(key: FilterMapKey): Observable<F>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets a default filter observable for the given key, used as a fallback when no explicit filter is set.
|
|
40
|
+
*
|
|
41
|
+
* @param key - filter map key
|
|
42
|
+
* @param obs - default filter observable or value
|
|
43
|
+
*/
|
|
15
44
|
addDefaultFilterObs(key: FilterMapKey, obs: Maybe<ObservableOrValue<F>>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Adds a filter observable for the given key. Multiple observables can be added per key
|
|
47
|
+
* and their emissions are merged together.
|
|
48
|
+
*
|
|
49
|
+
* @param key - filter map key
|
|
50
|
+
* @param obs - filter observable to add
|
|
51
|
+
*/
|
|
16
52
|
addFilterObs(key: FilterMapKey, obs: Observable<F>): void;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a {@link FilterMapKeyInstance} bound to the given key, providing both
|
|
55
|
+
* {@link FilterSource} and {@link FilterSourceConnector} interfaces for that key.
|
|
56
|
+
*
|
|
57
|
+
* @param key - filter map key to bind
|
|
58
|
+
* @returns instance for interacting with the filter at the given key
|
|
59
|
+
*/
|
|
17
60
|
makeInstance(key: FilterMapKey): FilterMapKeyInstance<F>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates an observable that emits a new {@link FilterMapKeyInstance} each time the key changes.
|
|
63
|
+
*
|
|
64
|
+
* @param keyObs - observable of filter map keys
|
|
65
|
+
* @returns observable that emits instances for the current key
|
|
66
|
+
*/
|
|
18
67
|
instanceObsForKeyObs(keyObs: Observable<FilterMapKey>): Observable<FilterMapKeyInstance<F>>;
|
|
19
68
|
private _itemForKey;
|
|
69
|
+
/**
|
|
70
|
+
* Destroys all filter items and completes the internal subject.
|
|
71
|
+
*/
|
|
20
72
|
destroy(): void;
|
|
21
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Bound instance of a {@link FilterMap} for a specific key.
|
|
76
|
+
*
|
|
77
|
+
* Implements both {@link FilterSource} (provides filter values) and {@link FilterSourceConnector}
|
|
78
|
+
* (accepts filter sources) for a single filter map entry.
|
|
79
|
+
*/
|
|
22
80
|
export declare class FilterMapKeyInstance<F> implements FilterSourceConnector<F>, FilterSource<F> {
|
|
23
81
|
private readonly _dbxFilterMap;
|
|
24
82
|
private readonly _key;
|
|
83
|
+
/**
|
|
84
|
+
* Observable of the filter value for this instance's key.
|
|
85
|
+
*/
|
|
25
86
|
readonly filter$: Observable<F>;
|
|
26
87
|
constructor(dbxFilterMap: FilterMap<F>, key: FilterMapKey);
|
|
27
88
|
get dbxFilterMap(): FilterMap<F>;
|
|
28
89
|
get key(): FilterMapKey;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the default filter observable for this key.
|
|
92
|
+
*/
|
|
29
93
|
initWithFilter(filterObs: Observable<F>): void;
|
|
94
|
+
/**
|
|
95
|
+
* Connects a filter source, adding its filter observable to this key's merged filters.
|
|
96
|
+
*/
|
|
30
97
|
connectWithSource(filterSource: FilterSource<F>): void;
|
|
31
98
|
}
|
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import { type FilterWithoutPresetString, type FilterWithPreset } from './filter';
|
|
2
2
|
import { type OperatorFunction } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Function that maps a filter with a preset reference into a concrete filter configuration
|
|
5
|
+
* with the preset field removed.
|
|
6
|
+
*/
|
|
3
7
|
export type MapFilterWithPresetFn<F extends FilterWithPreset> = (filter: F) => FilterWithoutPresetString<F>;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a mapping function that resolves preset references in filters.
|
|
10
|
+
*
|
|
11
|
+
* When a filter has a `preset` value, the provided function is called to expand the preset
|
|
12
|
+
* into concrete filter values, then the `preset` field is removed from the result.
|
|
13
|
+
* Filters without a preset are passed through unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @param fn - function that expands a preset into concrete filter values
|
|
16
|
+
* @returns mapping function that resolves presets and strips the preset field
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* interface MyFilter extends FilterWithPreset {
|
|
21
|
+
* active?: boolean;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* const resolve = makeMapFilterWithPresetFn<MyFilter>((f) => {
|
|
25
|
+
* if (f.preset === 'active') return { active: true };
|
|
26
|
+
* return { active: false };
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* const result = resolve({ preset: 'active' });
|
|
30
|
+
* // result === { active: true }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
4
33
|
export declare function makeMapFilterWithPresetFn<F extends FilterWithPreset>(fn: MapFilterWithPresetFn<F>): MapFilterWithPresetFn<F>;
|
|
34
|
+
/**
|
|
35
|
+
* RxJS operator that resolves preset references in a filter stream using the provided mapping function.
|
|
36
|
+
*
|
|
37
|
+
* @param fn - function that expands a preset into concrete filter values
|
|
38
|
+
* @returns operator that maps filter emissions, resolving any preset references
|
|
39
|
+
*/
|
|
5
40
|
export declare function mapFilterWithPreset<F extends FilterWithPreset>(fn: MapFilterWithPresetFn<F>): OperatorFunction<F, FilterWithoutPresetString<F>>;
|
|
@@ -2,13 +2,39 @@ import { type Observable } from 'rxjs';
|
|
|
2
2
|
import { type FilterSource } from './filter';
|
|
3
3
|
import { type MaybeObservableOrValue } from '../rxjs/getter';
|
|
4
4
|
import { type Destroyable, type Maybe } from '@dereekb/util';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for initializing a {@link FilterSourceInstance}.
|
|
7
|
+
*/
|
|
5
8
|
export interface FilterSourceInstanceConfig<F> {
|
|
9
|
+
/** Observable used to initialize the filter value, taking priority over the default. */
|
|
6
10
|
readonly initWithFilter?: Maybe<Observable<F>>;
|
|
11
|
+
/** Default filter value or observable, used as a fallback when no explicit filter is set. */
|
|
7
12
|
readonly defaultFilter?: MaybeObservableOrValue<F>;
|
|
13
|
+
/** Explicit filter value to set immediately. */
|
|
8
14
|
readonly filter?: Maybe<F>;
|
|
9
15
|
}
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
17
|
+
* Concrete implementation of {@link FilterSource} that manages reactive filter state with
|
|
18
|
+
* support for default values, initial values, and explicit overrides.
|
|
19
|
+
*
|
|
20
|
+
* Filter priority (highest to lowest):
|
|
21
|
+
* 1. Explicit filter set via {@link setFilter}
|
|
22
|
+
* 2. Initial filter set via {@link initWithFilter}
|
|
23
|
+
* 3. Default filter set via {@link setDefaultFilter}
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const source = new FilterSourceInstance<{ active: boolean }>();
|
|
28
|
+
*
|
|
29
|
+
* // Set a default filter
|
|
30
|
+
* source.setDefaultFilter(of({ active: false }));
|
|
31
|
+
*
|
|
32
|
+
* // Override with an explicit filter
|
|
33
|
+
* source.setFilter({ active: true });
|
|
34
|
+
*
|
|
35
|
+
* // Reset back to default
|
|
36
|
+
* source.resetFilter();
|
|
37
|
+
* ```
|
|
12
38
|
*/
|
|
13
39
|
export declare class FilterSourceInstance<F> implements FilterSource<F>, Destroyable {
|
|
14
40
|
private readonly _initialFilterSub;
|
|
@@ -19,21 +45,54 @@ export declare class FilterSourceInstance<F> implements FilterSource<F>, Destroy
|
|
|
19
45
|
*/
|
|
20
46
|
private readonly _initialFilter;
|
|
21
47
|
private readonly _defaultFilter;
|
|
48
|
+
/**
|
|
49
|
+
* Observable of the default filter value, emitting when a default is set.
|
|
50
|
+
*/
|
|
22
51
|
readonly defaultFilter$: Observable<Maybe<F>>;
|
|
52
|
+
/**
|
|
53
|
+
* Observable that emits the initial filter value, preferring the init filter over the default.
|
|
54
|
+
*/
|
|
23
55
|
readonly initialFilter$: Observable<Maybe<F>>;
|
|
24
56
|
/**
|
|
25
|
-
*
|
|
57
|
+
* Observable of the active filter value, resolving to the explicit filter if set,
|
|
58
|
+
* otherwise falling back to the initial/default filter. Deduplicated by deep value equality.
|
|
26
59
|
*/
|
|
27
60
|
readonly filter$: Observable<F>;
|
|
28
61
|
constructor(config?: FilterSourceInstanceConfig<F>);
|
|
62
|
+
/**
|
|
63
|
+
* Sets an initial filter observable that takes priority over the default filter.
|
|
64
|
+
*
|
|
65
|
+
* @param filterObs - observable providing the initial filter value
|
|
66
|
+
*/
|
|
29
67
|
initWithFilter(filterObs: Observable<F>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the default filter, used as a fallback when no explicit or initial filter is active.
|
|
70
|
+
*
|
|
71
|
+
* @param filter - default filter value, observable, or undefined to clear
|
|
72
|
+
*/
|
|
30
73
|
setDefaultFilter(filter: MaybeObservableOrValue<F>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Sets an explicit filter value that takes priority over the initial and default filters.
|
|
76
|
+
*
|
|
77
|
+
* @param filter - the filter value to set
|
|
78
|
+
*/
|
|
31
79
|
setFilter(filter: F): void;
|
|
32
80
|
/**
|
|
33
81
|
* Resets the current filter to be the default filter.
|
|
34
82
|
*/
|
|
35
83
|
resetFilter(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Controls whether changes to the initial filter automatically reset the explicit filter.
|
|
86
|
+
*
|
|
87
|
+
* When enabled, any new emission from the initial filter observable clears the explicit
|
|
88
|
+
* filter, causing `filter$` to fall back to the initial filter value.
|
|
89
|
+
*
|
|
90
|
+
* @param initialFilterTakesPriority - whether initial filter changes should reset the explicit filter
|
|
91
|
+
*/
|
|
36
92
|
setInitialFilterTakesPriority(initialFilterTakesPriority: boolean): void;
|
|
37
93
|
protected initFilterTakesPriority(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Completes all internal subjects and cleans up subscriptions.
|
|
96
|
+
*/
|
|
38
97
|
destroy(): void;
|
|
39
98
|
}
|
|
@@ -2,9 +2,13 @@ import { type Observable } from 'rxjs';
|
|
|
2
2
|
import { type MapFunctionOutputPair, type Destroyable, type IndexRef, type GetterOrValue, type MapFunction, type PromiseOrValue, type Page } from '@dereekb/util';
|
|
3
3
|
import { type ItemIteration, type PageItemIteration } from './iteration';
|
|
4
4
|
import { type LoadingState, type MapLoadingStateValueMapFunction } from '../loading';
|
|
5
|
+
/**
|
|
6
|
+
* Function that maps loaded values from their raw iteration type to the accumulator's output type.
|
|
7
|
+
*/
|
|
5
8
|
export type ItemAccumulatorMapFunction<O, I> = MapLoadingStateValueMapFunction<O, I>;
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
10
|
+
* Accumulates values from an {@link ItemIteration} into a growing collection,
|
|
11
|
+
* optionally mapping each value through a transform function.
|
|
8
12
|
*/
|
|
9
13
|
export interface ItemAccumulator<O, I = unknown, N extends ItemIteration<I> = ItemIteration<I>> {
|
|
10
14
|
/**
|
|
@@ -53,40 +57,62 @@ export type MonotypePageItemAccumulator<I, N extends PageItemIteration<I> = Page
|
|
|
53
57
|
*/
|
|
54
58
|
export interface ItemAccumulatorValuePair<O, I = unknown> extends MapFunctionOutputPair<O, LoadingState<I>>, IndexRef {
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Concrete accumulator instance with additional observables for tracking load progress
|
|
62
|
+
* and successful states.
|
|
63
|
+
*/
|
|
56
64
|
export interface ItemAccumulatorInstance<O, I = unknown, N extends ItemIteration<I> = ItemIteration<I>> extends ItemAccumulator<O, I, N>, Destroyable {
|
|
65
|
+
/** Emits `true` once the first load has completed. */
|
|
57
66
|
readonly hasCompletedInitialLoad$: Observable<boolean>;
|
|
67
|
+
/** The most recent loading state that completed without an error. */
|
|
58
68
|
readonly latestSuccessfulState$: Observable<LoadingState<I>>;
|
|
59
|
-
/**
|
|
60
|
-
* All successful page results in a single array.
|
|
61
|
-
*/
|
|
69
|
+
/** All successful loading states accumulated in order. */
|
|
62
70
|
readonly allSuccessfulStates$: Observable<LoadingState<I>[]>;
|
|
71
|
+
/** Count of successfully loaded pages so far. */
|
|
63
72
|
readonly successfulLoadCount$: Observable<number>;
|
|
64
73
|
}
|
|
65
74
|
/**
|
|
66
|
-
* Creates a new ItemAccumulatorInstance
|
|
75
|
+
* Creates a new {@link ItemAccumulatorInstance} that collects values from an {@link ItemIteration},
|
|
76
|
+
* optionally transforming each value through a mapping function.
|
|
77
|
+
*
|
|
78
|
+
* The accumulator subscribes to the iteration's states and builds up an array of all
|
|
79
|
+
* successfully loaded items over time. Error states are excluded from accumulation.
|
|
67
80
|
*
|
|
68
|
-
* @param itemIteration
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
81
|
+
* @param itemIteration - the iteration to accumulate values from
|
|
82
|
+
* @param inputMapItem - optional function to transform raw values into the desired output type
|
|
83
|
+
* @returns accumulator instance with observables for all collected items
|
|
71
84
|
*/
|
|
72
85
|
export declare function itemAccumulator<I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N): ItemAccumulatorInstance<I, I, N>;
|
|
73
86
|
export declare function itemAccumulator<O, I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N, mapItem?: ItemAccumulatorMapFunction<O, I>): ItemAccumulatorInstance<O, I, N>;
|
|
87
|
+
/**
|
|
88
|
+
* Function that counts the number of meaningful results in the accumulated items array.
|
|
89
|
+
*/
|
|
74
90
|
export type ItemAccumulatorNextPageUntilResultsCountFunction<O> = MapFunction<O[], PromiseOrValue<number>>;
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for {@link itemAccumulatorNextPageUntilResultsCount}.
|
|
93
|
+
*/
|
|
75
94
|
export interface ItemAccumulatorNextPageUntilResultsCountConfig<O> {
|
|
95
|
+
/** The accumulator whose iteration will be advanced. */
|
|
76
96
|
readonly accumulator: ItemAccumulator<O, any, PageItemIteration<any>>;
|
|
97
|
+
/** Target number of results to accumulate before stopping. */
|
|
77
98
|
readonly maxResultsLimit: GetterOrValue<number>;
|
|
99
|
+
/** Function to count how many meaningful results exist in the accumulated items. */
|
|
78
100
|
readonly countResultsFunction: ItemAccumulatorNextPageUntilResultsCountFunction<O>;
|
|
79
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Result of {@link itemAccumulatorNextPageUntilResultsCount} containing the final page
|
|
104
|
+
* and total results count.
|
|
105
|
+
*/
|
|
80
106
|
export interface ItemAccumulatorNextPageUntilResultsCountResult extends Page {
|
|
81
107
|
readonly resultsCount: number;
|
|
82
108
|
}
|
|
83
109
|
/**
|
|
84
|
-
* Automatically
|
|
110
|
+
* Automatically pages through an accumulator's iteration until the desired number of results
|
|
111
|
+
* is reached or no more pages are available.
|
|
85
112
|
*
|
|
86
|
-
*
|
|
113
|
+
* @param config - configuration specifying the accumulator, result limit, and counting function
|
|
114
|
+
* @returns promise resolving to the final page number and total results count
|
|
87
115
|
*
|
|
88
|
-
* @
|
|
89
|
-
* @param maxResultsLimit
|
|
90
|
-
* @returns
|
|
116
|
+
* @throws Rejects if the iteration encounters an error during loading
|
|
91
117
|
*/
|
|
92
118
|
export declare function itemAccumulatorNextPageUntilResultsCount<O>(config: ItemAccumulatorNextPageUntilResultsCountConfig<O>): Promise<ItemAccumulatorNextPageUntilResultsCountResult>;
|
|
@@ -2,24 +2,41 @@ import { type Observable } from 'rxjs';
|
|
|
2
2
|
import { type PageListLoadingState } from '../loading';
|
|
3
3
|
import { type ItemAccumulator, type PageItemAccumulator } from './iteration.accumulator';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Flattens paginated array results from an {@link ItemAccumulator} into a single growing array.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Designed for accumulators where each page returns an array of items. Concatenates all
|
|
8
|
+
* page results into one flat array that grows as new pages are loaded.
|
|
9
|
+
*
|
|
10
|
+
* @param accumulator - accumulator whose page results are arrays to flatten
|
|
11
|
+
* @returns observable emitting the flattened array of all accumulated items
|
|
9
12
|
*/
|
|
10
13
|
export declare function flattenAccumulatorResultItemArray<T, I = unknown>(accumulator: ItemAccumulator<T[], I>): Observable<T[]>;
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
15
|
+
* Combines a page accumulator's flattened array results with its current loading state
|
|
16
|
+
* into a single {@link PageListLoadingState} observable.
|
|
17
|
+
*
|
|
18
|
+
* The loading state reflects whether a page is currently being fetched, while the value
|
|
19
|
+
* always contains the full flattened array of all items loaded so far.
|
|
20
|
+
*
|
|
21
|
+
* @param accumulator - page accumulator whose results are arrays to flatten
|
|
22
|
+
* @returns observable of the combined loading state with all accumulated items
|
|
13
23
|
*/
|
|
14
24
|
export declare function accumulatorFlattenPageListLoadingState<T, I = unknown>(accumulator: PageItemAccumulator<T[], I>): Observable<PageListLoadingState<T>>;
|
|
15
25
|
/**
|
|
16
|
-
*
|
|
26
|
+
* Combines a page accumulator's collected items with its current loading state
|
|
27
|
+
* into a single {@link PageListLoadingState} observable.
|
|
28
|
+
*
|
|
29
|
+
* Unlike {@link accumulatorFlattenPageListLoadingState}, this does not flatten arrays —
|
|
30
|
+
* each accumulated value is included as-is.
|
|
31
|
+
*
|
|
32
|
+
* @param accumulator - page accumulator to observe
|
|
33
|
+
* @returns observable of the combined loading state with all accumulated items
|
|
17
34
|
*/
|
|
18
35
|
export declare function accumulatorCurrentPageListLoadingState<V, I = unknown>(accumulator: PageItemAccumulator<V, I>): Observable<PageListLoadingState<V>>;
|
|
19
36
|
/**
|
|
20
|
-
* Returns the latest loaded page number from the input
|
|
37
|
+
* Returns the latest loaded page number from the input accumulator's underlying iteration.
|
|
21
38
|
*
|
|
22
|
-
* @param pageItemAccumulator
|
|
23
|
-
* @returns
|
|
39
|
+
* @param pageItemAccumulator - accumulator to observe the current page from
|
|
40
|
+
* @returns observable emitting the most recently loaded page number
|
|
24
41
|
*/
|
|
25
42
|
export declare function pageItemAccumulatorCurrentPage(pageItemAccumulator: PageItemAccumulator<any, any>): Observable<number>;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
2
|
import { type Destroyable, type Maybe, type PageNumber } from '@dereekb/util';
|
|
3
3
|
import { type LoadingState, type PageLoadingState } from '../loading';
|
|
4
|
+
/**
|
|
5
|
+
* Request parameters for triggering the next load in an {@link ItemIteration}.
|
|
6
|
+
*/
|
|
4
7
|
export interface ItemIteratorNextRequest {
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* If provided, the page must equal the target page, otherwise the next is ignored.
|
|
9
|
+
* Target page number to load. If provided and the iterator is not on this page,
|
|
10
|
+
* the request is ignored to prevent out-of-order loading.
|
|
9
11
|
*/
|
|
10
12
|
page?: number;
|
|
11
13
|
/**
|
|
12
|
-
* Whether
|
|
14
|
+
* Whether to retry loading the current page after an error.
|
|
13
15
|
*/
|
|
14
16
|
retry?: boolean;
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Reactive iterator that loads items incrementally and exposes loading state as observables.
|
|
20
|
+
*
|
|
21
|
+
* Consumers call {@link next} to trigger loading of the next batch and observe results
|
|
22
|
+
* through the various state observables.
|
|
23
|
+
*/
|
|
16
24
|
export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingState<V>> extends Destroyable {
|
|
17
25
|
/**
|
|
18
26
|
* Whether or not there are more items to be loaded.
|
|
@@ -48,7 +56,10 @@ export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingS
|
|
|
48
56
|
next(request?: ItemIteratorNextRequest): void;
|
|
49
57
|
}
|
|
50
58
|
/**
|
|
51
|
-
*
|
|
59
|
+
* Extension of {@link ItemIteration} that supports paginated loading with page numbers.
|
|
60
|
+
*
|
|
61
|
+
* Adds page-specific operations like {@link nextPage} (promise-based) and page load limits
|
|
62
|
+
* to prevent unbounded iteration.
|
|
52
63
|
*/
|
|
53
64
|
export interface PageItemIteration<V = unknown, L extends PageLoadingState<V> = PageLoadingState<V>> extends ItemIteration<V, L> {
|
|
54
65
|
/**
|
|
@@ -3,7 +3,8 @@ import { type Destroyable } from '@dereekb/util';
|
|
|
3
3
|
import { type Observable } from 'rxjs';
|
|
4
4
|
import { type ItemIteration, type ItemIteratorNextRequest } from './iteration';
|
|
5
5
|
/**
|
|
6
|
-
* An
|
|
6
|
+
* An {@link ItemIteration} wrapper that transforms loading state values from one type to another
|
|
7
|
+
* while preserving the iteration interface.
|
|
7
8
|
*/
|
|
8
9
|
export interface MappedItemIteration<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>> extends ItemIteration<O, M> {
|
|
9
10
|
/**
|
|
@@ -11,12 +12,21 @@ export interface MappedItemIteration<O, I = unknown, M extends LoadingState<O> =
|
|
|
11
12
|
*/
|
|
12
13
|
readonly itemIteration: N;
|
|
13
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for creating a {@link MappedItemIterationInstance}, extending the loading state
|
|
17
|
+
* mapping configuration with lifecycle options.
|
|
18
|
+
*/
|
|
14
19
|
export interface MappedItemIterationInstanceMapConfig<O, I, M extends LoadingState<O> = PageLoadingState<O>, L extends LoadingState<I> = PageLoadingState<I>> extends MapLoadingStateResultsConfiguration<I, O, L, M> {
|
|
15
20
|
/**
|
|
16
|
-
* Whether
|
|
21
|
+
* Whether destroying the mapped instance also destroys the underlying iteration.
|
|
22
|
+
* Defaults to `true`.
|
|
17
23
|
*/
|
|
18
24
|
forwardDestroy?: boolean;
|
|
19
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Concrete instance of a mapped item iteration, exposing the transformed state observables
|
|
28
|
+
* and the underlying iterator and configuration.
|
|
29
|
+
*/
|
|
20
30
|
export interface MappedItemIterationInstance<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>> extends ItemIteration<O>, Destroyable {
|
|
21
31
|
readonly itemIterator: N;
|
|
22
32
|
readonly config: MappedItemIterationInstanceMapConfig<O, I, M, L>;
|
|
@@ -28,10 +38,13 @@ export interface MappedItemIterationInstance<O, I = unknown, M extends LoadingSt
|
|
|
28
38
|
next(request?: ItemIteratorNextRequest): void;
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
|
-
* Creates a
|
|
41
|
+
* Creates a {@link MappedItemIterationInstance} that wraps an existing iteration and transforms
|
|
42
|
+
* its loading state values through the provided mapping configuration.
|
|
43
|
+
*
|
|
44
|
+
* Control flow (next, hasNext, canLoadMore) is delegated directly to the underlying iteration.
|
|
32
45
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param config
|
|
35
|
-
* @returns
|
|
46
|
+
* @param itemIterator - the source iteration to wrap
|
|
47
|
+
* @param config - mapping configuration for transforming loading state values
|
|
48
|
+
* @returns mapped iteration instance with transformed state observables
|
|
36
49
|
*/
|
|
37
50
|
export declare function mapItemIteration<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>>(itemIterator: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>): MappedItemIterationInstance<O, I, M, L, N>;
|
|
@@ -2,19 +2,22 @@ import { type PageLoadingState } from '../loading';
|
|
|
2
2
|
import { type PageItemIteration } from './iteration';
|
|
3
3
|
import { type MappedItemIteration, type MappedItemIterationInstance, type MappedItemIterationInstanceMapConfig } from './iteration.mapped';
|
|
4
4
|
/**
|
|
5
|
-
* MappedItemIteration for PageItemIteration
|
|
5
|
+
* {@link MappedItemIteration} specialized for {@link PageItemIteration}, preserving page-specific loading state types.
|
|
6
6
|
*/
|
|
7
7
|
export type MappedPageItemIteration<O, I = unknown, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>> = MappedItemIteration<O, I, M, L, N>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Instance of a mapped page iteration that implements both {@link MappedItemIterationInstance}
|
|
10
|
+
* and {@link PageItemIteration}, providing transformed states alongside page-specific operations.
|
|
10
11
|
*/
|
|
11
12
|
export interface MappedPageItemIterationInstance<O, I = unknown, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>> extends MappedItemIterationInstance<O, I, M, L, N>, PageItemIteration<O, M> {
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* Creates a
|
|
15
|
+
* Creates a {@link MappedPageItemIterationInstance} that wraps a {@link PageItemIteration}
|
|
16
|
+
* and transforms its loading state values while preserving page-level operations
|
|
17
|
+
* (nextPage, page load limits, latestLoadedPage).
|
|
15
18
|
*
|
|
16
|
-
* @param itemIteration
|
|
17
|
-
* @param config
|
|
18
|
-
* @returns
|
|
19
|
+
* @param itemIteration - the source page iteration to wrap
|
|
20
|
+
* @param config - mapping configuration for transforming loading state values
|
|
21
|
+
* @returns mapped page iteration instance
|
|
19
22
|
*/
|
|
20
23
|
export declare function mappedPageItemIteration<O, I = unknown, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>>(itemIteration: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>): MappedPageItemIterationInstance<O, I, M, L, N>;
|