@dereekb/rxjs 13.43.0 → 14.0.1

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dereekb/rxjs",
3
- "version": "13.43.0",
3
+ "version": "14.0.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "rxjs": "^7.8.2",
8
- "@dereekb/util": "13.43.0"
8
+ "@dereekb/util": "14.0.1"
9
9
  },
10
10
  "exports": {
11
11
  "./package.json": "./package.json",
@@ -1,16 +1,16 @@
1
1
  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
- import { type LoadingState, type MapLoadingStateValueMapFunction } from '../loading';
4
+ import { type LoadingState, type PageLoadingState, type MapLoadingStateValueMapFunction } from '../loading';
5
5
  /**
6
6
  * Function that maps loaded values from their raw iteration type to the accumulator's output type.
7
7
  */
8
- export type ItemAccumulatorMapFunction<O, I> = MapLoadingStateValueMapFunction<O, I>;
8
+ export type ItemAccumulatorMapFunction<O, I> = MapLoadingStateValueMapFunction<LoadingState<I>, O>;
9
9
  /**
10
10
  * Accumulates values from an {@link ItemIteration} into a growing collection,
11
11
  * optionally mapping each value through a transform function.
12
12
  */
13
- export interface ItemAccumulator<O, I = unknown, N extends ItemIteration<I> = ItemIteration<I>> {
13
+ export interface ItemAccumulator<O, I = unknown, N extends ItemIteration<LoadingState<I>> = ItemIteration<LoadingState<I>>> {
14
14
  /**
15
15
  * Iteration being accumulated.
16
16
  */
@@ -43,15 +43,15 @@ export interface ItemAccumulator<O, I = unknown, N extends ItemIteration<I> = It
43
43
  /**
44
44
  * An object that accumulates and exposes values from a PageItemIteration.
45
45
  */
46
- export type PageItemAccumulator<O, I = unknown, N extends PageItemIteration<I> = PageItemIteration<I>> = ItemAccumulator<O, I, N>;
46
+ export type PageItemAccumulator<O, I = unknown, N extends PageItemIteration<PageLoadingState<I>> = PageItemIteration<PageLoadingState<I>>> = ItemAccumulator<O, I, N>;
47
47
  /**
48
48
  * An accumulator with no mapping.
49
49
  */
50
- export type MonotypeItemAccumulator<I, N extends ItemIteration<I> = ItemIteration<I>> = ItemAccumulator<I, I, N>;
50
+ export type MonotypeItemAccumulator<I, N extends ItemIteration<LoadingState<I>> = ItemIteration<LoadingState<I>>> = ItemAccumulator<I, I, N>;
51
51
  /**
52
52
  * A page accumulator with no mapping.
53
53
  */
54
- export type MonotypePageItemAccumulator<I, N extends PageItemIteration<I> = PageItemIteration<I>> = ItemAccumulator<I, I, N>;
54
+ export type MonotypePageItemAccumulator<I, N extends PageItemIteration<PageLoadingState<I>> = PageItemIteration<PageLoadingState<I>>> = ItemAccumulator<I, I, N>;
55
55
  /**
56
56
  * Value of an item accumulator.
57
57
  */
@@ -61,7 +61,7 @@ export interface ItemAccumulatorValuePair<O, I = unknown> extends MapFunctionOut
61
61
  * Concrete accumulator instance with additional observables for tracking load progress
62
62
  * and successful states.
63
63
  */
64
- export interface ItemAccumulatorInstance<O, I = unknown, N extends ItemIteration<I> = ItemIteration<I>> extends ItemAccumulator<O, I, N>, Destroyable {
64
+ export interface ItemAccumulatorInstance<O, I = unknown, N extends ItemIteration<LoadingState<I>> = ItemIteration<LoadingState<I>>> extends ItemAccumulator<O, I, N>, Destroyable {
65
65
  /**
66
66
  * Emits `true` once the first load has completed.
67
67
  */
@@ -90,8 +90,8 @@ export interface ItemAccumulatorInstance<O, I = unknown, N extends ItemIteration
90
90
  * @param inputMapItem - optional function to transform raw values into the desired output type
91
91
  * @returns accumulator instance with observables for all collected items
92
92
  */
93
- export declare function itemAccumulator<I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N): ItemAccumulatorInstance<I, I, N>;
94
- export declare function itemAccumulator<O, I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N, mapItem?: ItemAccumulatorMapFunction<O, I>): ItemAccumulatorInstance<O, I, N>;
93
+ export declare function itemAccumulator<I, N extends ItemIteration<LoadingState<I>> = ItemIteration<LoadingState<I>>>(itemIteration: N): ItemAccumulatorInstance<I, I, N>;
94
+ export declare function itemAccumulator<O, I, N extends ItemIteration<LoadingState<I>> = ItemIteration<LoadingState<I>>>(itemIteration: N, mapItem?: ItemAccumulatorMapFunction<O, I>): ItemAccumulatorInstance<O, I, N>;
95
95
  /**
96
96
  * Function that counts the number of meaningful results in the accumulated items array.
97
97
  */
@@ -103,7 +103,7 @@ export interface ItemAccumulatorNextPageUntilResultsCountConfig<O> {
103
103
  /**
104
104
  * The accumulator whose iteration will be advanced.
105
105
  */
106
- readonly accumulator: ItemAccumulator<O, any, PageItemIteration<any>>;
106
+ readonly accumulator: ItemAccumulator<O, any, PageItemIteration<PageLoadingState<any>>>;
107
107
  /**
108
108
  * Target number of results to accumulate before stopping.
109
109
  */
@@ -21,7 +21,7 @@ export interface ItemIteratorNextRequest {
21
21
  * Consumers call {@link next} to trigger loading of the next batch and observe results
22
22
  * through the various state observables.
23
23
  */
24
- export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingState<V>> extends Destroyable {
24
+ export interface ItemIteration<L extends LoadingState = LoadingState> extends Destroyable {
25
25
  /**
26
26
  * Whether or not there are more items to be loaded.
27
27
  *
@@ -61,7 +61,7 @@ export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingS
61
61
  * Adds page-specific operations like {@link nextPage} (promise-based) and page load limits
62
62
  * to prevent unbounded iteration.
63
63
  */
64
- export interface PageItemIteration<V = unknown, L extends PageLoadingState<V> = PageLoadingState<V>> extends ItemIteration<V, L> {
64
+ export interface PageItemIteration<L extends PageLoadingState = PageLoadingState> extends ItemIteration<L> {
65
65
  /**
66
66
  * Returns the maximum number of pages allowed to be loaded.
67
67
  *
@@ -1,4 +1,4 @@
1
- import { type LoadingState, type MapLoadingStateResultsConfiguration, type PageLoadingState } from '../loading';
1
+ import { type LoadingState, type LoadingStateValue, type MapLoadingStateResultsConfiguration } from '../loading';
2
2
  import { type Destroyable } from '@dereekb/util';
3
3
  import { type Observable } from 'rxjs';
4
4
  import { type ItemIteration, type ItemIteratorNextRequest } from './iteration';
@@ -6,7 +6,7 @@ import { type ItemIteration, type ItemIteratorNextRequest } from './iteration';
6
6
  * An {@link ItemIteration} wrapper that transforms loading state values from one type to another
7
7
  * while preserving the iteration interface.
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
+ export interface MappedItemIteration<M extends LoadingState, L extends LoadingState, N extends ItemIteration<L> = ItemIteration<L>> extends ItemIteration<M> {
10
10
  /**
11
11
  * Iteration being accumulated.
12
12
  */
@@ -16,7 +16,7 @@ export interface MappedItemIteration<O, I = unknown, M extends LoadingState<O> =
16
16
  * Configuration for creating a {@link MappedItemIterationInstance}, extending the loading state
17
17
  * mapping configuration with lifecycle options.
18
18
  */
19
- export interface MappedItemIterationInstanceMapConfig<O, I, M extends LoadingState<O> = PageLoadingState<O>, L extends LoadingState<I> = PageLoadingState<I>> extends MapLoadingStateResultsConfiguration<I, O, L, M> {
19
+ export interface MappedItemIterationInstanceMapConfig<L extends LoadingState, M extends LoadingState> extends MapLoadingStateResultsConfiguration<L, LoadingStateValue<M>, M> {
20
20
  /**
21
21
  * Whether destroying the mapped instance also destroys the underlying iteration.
22
22
  * Defaults to `true`.
@@ -27,9 +27,9 @@ export interface MappedItemIterationInstanceMapConfig<O, I, M extends LoadingSta
27
27
  * Concrete instance of a mapped item iteration, exposing the transformed state observables
28
28
  * and the underlying iterator and configuration.
29
29
  */
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 {
30
+ export interface MappedItemIterationInstance<M extends LoadingState, L extends LoadingState, N extends ItemIteration<L> = ItemIteration<L>> extends ItemIteration<M>, Destroyable {
31
31
  readonly itemIterator: N;
32
- readonly config: MappedItemIterationInstanceMapConfig<O, I, M, L>;
32
+ readonly config: MappedItemIterationInstanceMapConfig<L, M>;
33
33
  readonly hasNext$: Observable<boolean>;
34
34
  readonly canLoadMore$: Observable<boolean>;
35
35
  readonly firstState$: Observable<M>;
@@ -47,4 +47,4 @@ export interface MappedItemIterationInstance<O, I = unknown, M extends LoadingSt
47
47
  * @param config - Mapping configuration for transforming loading state values.
48
48
  * @returns Mapped iteration instance with transformed state observables.
49
49
  */
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>;
50
+ export declare function mapItemIteration<M extends LoadingState, L extends LoadingState, N extends ItemIteration<L> = ItemIteration<L>>(itemIterator: N, config: MappedItemIterationInstanceMapConfig<L, M>): MappedItemIterationInstance<M, L, N>;
@@ -4,12 +4,12 @@ import { type MappedItemIteration, type MappedItemIterationInstance, type Mapped
4
4
  /**
5
5
  * {@link MappedItemIteration} specialized for {@link PageItemIteration}, preserving page-specific loading state types.
6
6
  */
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>;
7
+ export type MappedPageItemIteration<M extends PageLoadingState, L extends PageLoadingState, N extends PageItemIteration<L> = PageItemIteration<L>> = MappedItemIteration<M, L, N>;
8
8
  /**
9
9
  * Instance of a mapped page iteration that implements both {@link MappedItemIterationInstance}
10
10
  * and {@link PageItemIteration}, providing transformed states alongside page-specific operations.
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
+ export interface MappedPageItemIterationInstance<M extends PageLoadingState, L extends PageLoadingState, N extends PageItemIteration<L> = PageItemIteration<L>> extends MappedItemIterationInstance<M, L, N>, PageItemIteration<M> {
13
13
  }
14
14
  /**
15
15
  * Creates a {@link MappedPageItemIterationInstance} that wraps a {@link PageItemIteration}
@@ -20,4 +20,4 @@ export interface MappedPageItemIterationInstance<O, I = unknown, M extends PageL
20
20
  * @param config - Mapping configuration for transforming loading state values.
21
21
  * @returns Mapped page iteration instance.
22
22
  */
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>;
23
+ export declare function mappedPageItemIteration<M extends PageLoadingState, L extends PageLoadingState, N extends PageItemIteration<L> = PageItemIteration<L>>(itemIteration: N, config: MappedItemIterationInstanceMapConfig<L, M>): MappedPageItemIterationInstance<M, L, N>;
@@ -8,7 +8,7 @@ import { type Maybe, type GetterOrValue, type PageNumber } from '@dereekb/util';
8
8
  * @param iteration - The iteration to check.
9
9
  * @returns Observable that emits `true` when more items can be loaded.
10
10
  */
11
- export declare function iterationHasNextAndCanLoadMore<V>(iteration: ItemIteration<V>): Observable<boolean>;
11
+ export declare function iterationHasNextAndCanLoadMore(iteration: ItemIteration): Observable<boolean>;
12
12
  /**
13
13
  * Automatically pages through a {@link PageItemIteration} until its configured max page load limit is reached.
14
14
  *
@@ -143,7 +143,7 @@ export interface ItemPageIterationInstanceState<V> {
143
143
  * tracking loading/success/error states, and exposing all results as reactive observables.
144
144
  * Implements {@link PageItemIteration} for use with accumulators and other iteration utilities.
145
145
  */
146
- export declare class ItemPageIterationInstance<V, F, C extends ItemPageIterationConfig<F> = ItemPageIterationConfig<F>> implements PageItemIteration<V, PageLoadingState<V>>, Destroyable {
146
+ export declare class ItemPageIterationInstance<V, F, C extends ItemPageIterationConfig<F> = ItemPageIterationConfig<F>> implements PageItemIteration<PageLoadingState<V>>, Destroyable {
147
147
  private readonly _iterator;
148
148
  private readonly _config;
149
149
  /**
@@ -2,19 +2,19 @@ import { type LimitArrayConfig, type Maybe } from '@dereekb/util';
2
2
  import { type Observable } from 'rxjs';
3
3
  import { type ListLoadingState } from './loading.state';
4
4
  import { type LoadingStateContext, type LoadingStateContextConfig, type LoadingStateContextInput, type MutableLoadingStateContext } from './loading.context.state';
5
- export interface ListLoadingStateContext<L = unknown, S extends ListLoadingState<L> = ListLoadingState<L>> extends Omit<LoadingStateContext<L[], S>, 'value$' | 'currentValue$' | 'valueAfterLoaded$'> {
5
+ export interface ListLoadingStateContext<T = unknown, S extends ListLoadingState<T> = ListLoadingState<T>> extends Omit<LoadingStateContext<T[], S>, 'value$' | 'currentValue$' | 'valueAfterLoaded$'> {
6
6
  /**
7
7
  * The current list. Always provided, even while loading.
8
8
  */
9
- readonly currentList$: Observable<Maybe<L[]>>;
9
+ readonly currentList$: Observable<Maybe<T[]>>;
10
10
  /**
11
11
  * The latest list from the most recent loaded state.
12
12
  */
13
- readonly listAfterLoaded$: Observable<Maybe<L[]>>;
13
+ readonly listAfterLoaded$: Observable<Maybe<T[]>>;
14
14
  /**
15
15
  * The latest list from listAfterLoaded$, or a default value if the list was empty.
16
16
  */
17
- readonly list$: Observable<L[]>;
17
+ readonly list$: Observable<T[]>;
18
18
  /**
19
19
  * Whether or not the currentList$ value is empty.
20
20
  *
@@ -39,15 +39,15 @@ export interface ListLoadingStateContext<L = unknown, S extends ListLoadingState
39
39
  /**
40
40
  * A ListLoadingStateContext that can be updated and destroyed.
41
41
  */
42
- export type MutableListLoadingStateContext<L = unknown, S extends ListLoadingState<L> = ListLoadingState<L>> = ListLoadingStateContext<L, S> & Pick<MutableLoadingStateContext<L[], S>, 'setStateObs' | 'destroy'>;
42
+ export type MutableListLoadingStateContext<T = unknown, S extends ListLoadingState<T> = ListLoadingState<T>> = ListLoadingStateContext<T, S> & Pick<MutableLoadingStateContext<T[], S>, 'setStateObs' | 'destroy'>;
43
43
  /**
44
44
  * Configuration for listLoadingStateContext().
45
45
  */
46
- export type ListLoadingStateContextConfig<L, S extends ListLoadingState<L> = ListLoadingState<L>> = Omit<LoadingStateContextConfig<L[], S>, 'loadingEventForLoadingPair'> & Partial<LimitArrayConfig>;
46
+ export type ListLoadingStateContextConfig<T, S extends ListLoadingState<T> = ListLoadingState<T>> = Omit<LoadingStateContextConfig<T[], S>, 'loadingEventForLoadingPair'> & Partial<LimitArrayConfig>;
47
47
  /**
48
48
  * Input for listLoadingStateContext().
49
49
  */
50
- export type ListLoadingStateContextInput<L, S extends ListLoadingState<L> = ListLoadingState<L>> = Omit<LoadingStateContextInput<L[], S>, 'loadingEventForLoadingPair'> | ListLoadingStateContextConfig<L, S>;
50
+ export type ListLoadingStateContextInput<T, S extends ListLoadingState<T> = ListLoadingState<T>> = Omit<LoadingStateContextInput<T[], S>, 'loadingEventForLoadingPair'> | ListLoadingStateContextConfig<T, S>;
51
51
  /**
52
52
  * Creates a {@link MutableListLoadingStateContext} that wraps a {@link ListLoadingState} observable
53
53
  * and provides list-specific reactive accessors like `isEmpty$` and `list$`.
@@ -76,4 +76,4 @@ export type ListLoadingStateContextInput<L, S extends ListLoadingState<L> = List
76
76
  * context.destroy();
77
77
  * ```
78
78
  */
79
- export declare function listLoadingStateContext<L, S extends ListLoadingState<L> = ListLoadingState<L>>(input?: ListLoadingStateContextInput<L, S>): MutableListLoadingStateContext<L, S>;
79
+ export declare function listLoadingStateContext<T, S extends ListLoadingState<T> = ListLoadingState<T>>(input?: ListLoadingStateContextInput<T, S>): MutableListLoadingStateContext<T, S>;