@dereekb/rxjs 13.0.4 → 13.0.6

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 CHANGED
@@ -2753,9 +2753,25 @@ function _unsupported_iterable_to_array$3(o, minLen) {
2753
2753
  }
2754
2754
  // TODO(BREAKING_CHANGE): Fix all LoadingState types to use the LoadingStateValue inference typings
2755
2755
  /**
2756
- * Wraps an observable output and maps the value to a LoadingState.
2756
+ * Wraps an observable output and maps the value to a {@link LoadingState}.
2757
+ *
2758
+ * Emits a loading state immediately, then emits a success result when the observable emits a value,
2759
+ * or an error result if the observable errors.
2757
2760
  *
2758
2761
  * If firstOnly is provided, it will only take the first value the observable returns.
2762
+ *
2763
+ * @example
2764
+ * ```ts
2765
+ * // Wrap a data fetch observable into a LoadingState
2766
+ * readonly jsonContentState$ = loadingStateFromObs(this.jsonContent$);
2767
+ *
2768
+ * // Wrap an observable and only take the first emitted value
2769
+ * readonly singleValueState$ = loadingStateFromObs(this.data$, true);
2770
+ * ```
2771
+ *
2772
+ * @param obs - The source observable to wrap.
2773
+ * @param firstOnly - If true, only takes the first value from the observable.
2774
+ * @returns An observable that emits {@link LoadingState} values representing the loading lifecycle.
2759
2775
  */ function loadingStateFromObs(obs, firstOnly) {
2760
2776
  if (firstOnly) {
2761
2777
  obs = obs.pipe(rxjs.first());
@@ -2792,10 +2808,27 @@ function combineLoadingStates() {
2792
2808
  );
2793
2809
  }
2794
2810
  /**
2795
- * Combines the status of all loading states. Only emits when the LoadingStateType of the result changes, or the loading state progress.
2811
+ * Combines the status of all loading states into a single {@link LoadingState}<boolean>.
2796
2812
  *
2797
- * @param sources
2798
- * @returns
2813
+ * Only emits when the {@link LoadingStateType} of the result changes, or the loading state progress changes.
2814
+ * If any source has an error, the error is propagated. If any source is still loading, the result is loading.
2815
+ * When all sources are successful, the result value is `true`.
2816
+ *
2817
+ * @example
2818
+ * ```ts
2819
+ * const success$ = of(successResult(1));
2820
+ * const success2$ = of(successResult(2));
2821
+ *
2822
+ * // All success => emits { value: true }
2823
+ * const status$ = combineLoadingStatesStatus([success$, success2$]);
2824
+ *
2825
+ * // One loading => emits loading state
2826
+ * const loading$ = of(beginLoading());
2827
+ * const status$ = combineLoadingStatesStatus([loading$, success$]);
2828
+ * ```
2829
+ *
2830
+ * @param sources - An array of LoadingState observables to combine.
2831
+ * @returns An observable emitting a {@link LoadingState}<boolean> representing the combined status.
2799
2832
  */ function combineLoadingStatesStatus(sources) {
2800
2833
  return rxjs.combineLatest(sources).pipe(rxjs.map(function(allLoadingStates) {
2801
2834
  var firstErrorState = allLoadingStates.find(function(x) {
@@ -2821,7 +2854,20 @@ function startWithBeginLoading(state) {
2821
2854
  return rxjs.startWith(beginLoading(state));
2822
2855
  }
2823
2856
  /**
2824
- * Returns the current value from the LoadingState.
2857
+ * Returns the current value from the {@link LoadingState}, including `undefined` when still loading or no value is set.
2858
+ *
2859
+ * Unlike {@link valueFromLoadingState}, this operator emits for every state change, regardless of whether the value is defined.
2860
+ *
2861
+ * @example
2862
+ * ```ts
2863
+ * // Expose the current (possibly undefined) value from a loading state
2864
+ * const currentValue$: Observable<Maybe<T>> = state$.pipe(
2865
+ * currentValueFromLoadingState(),
2866
+ * shareReplay(1)
2867
+ * );
2868
+ * ```
2869
+ *
2870
+ * @returns An `OperatorFunction` that maps each {@link LoadingState} to its current value (or undefined).
2825
2871
  */ function currentValueFromLoadingState() {
2826
2872
  return function(obs) {
2827
2873
  return obs.pipe(rxjs.map(function(x) {
@@ -2830,9 +2876,21 @@ function startWithBeginLoading(state) {
2830
2876
  };
2831
2877
  }
2832
2878
  /**
2833
- * Returns the current non-null value from the LoadingState.
2879
+ * Returns the current non-null/non-undefined value from the {@link LoadingState}.
2834
2880
  *
2835
- * Equivalent to currentValueFromLoadingState() and filterMaybe().
2881
+ * Equivalent to piping {@link currentValueFromLoadingState} and `filterMaybeStrict()`.
2882
+ * Only emits when the value is defined, filtering out loading and error states without values.
2883
+ *
2884
+ * @example
2885
+ * ```ts
2886
+ * // Only emit when the loading state has a defined value
2887
+ * const value$ = state$.pipe(
2888
+ * valueFromLoadingState(),
2889
+ * // only emits non-null/non-undefined values
2890
+ * );
2891
+ * ```
2892
+ *
2893
+ * @returns An `OperatorFunction` that emits only defined values from the {@link LoadingState}.
2836
2894
  */ function valueFromLoadingState() {
2837
2895
  return function(obs) {
2838
2896
  return obs.pipe(rxjs.map(function(x) {
@@ -2841,7 +2899,20 @@ function startWithBeginLoading(state) {
2841
2899
  };
2842
2900
  }
2843
2901
  /**
2844
- * Returns the error once the LoadingState has finished loading with an error.
2902
+ * Returns the error once the {@link LoadingState} has finished loading with an error.
2903
+ *
2904
+ * Filters to only emit when the state contains an error, then extracts and emits the {@link ReadableError}.
2905
+ *
2906
+ * @example
2907
+ * ```ts
2908
+ * // React to errors from a loading state
2909
+ * state$.pipe(
2910
+ * errorFromLoadingState(),
2911
+ * tap((error) => console.error('Loading failed:', error))
2912
+ * ).subscribe();
2913
+ * ```
2914
+ *
2915
+ * @returns An `OperatorFunction` that emits the {@link ReadableError} from error states.
2845
2916
  */ function errorFromLoadingState() {
2846
2917
  return function(obs) {
2847
2918
  return obs.pipe(rxjs.filter(isLoadingStateWithError), rxjs.map(function(x) {
@@ -2850,7 +2921,23 @@ function startWithBeginLoading(state) {
2850
2921
  };
2851
2922
  }
2852
2923
  /**
2853
- * Throws an error if the LoadingState value has an error.
2924
+ * Throws an error if the {@link LoadingState} value has an error.
2925
+ *
2926
+ * Passes through non-error states unchanged, but throws the error from any {@link LoadingStateWithError},
2927
+ * converting the loading state error into an observable error that can be caught with `catchError`.
2928
+ *
2929
+ * @example
2930
+ * ```ts
2931
+ * // Convert a LoadingState observable to a Promise, throwing on error states
2932
+ * const result = await firstValueFrom(
2933
+ * loadingState$.pipe(
2934
+ * throwErrorFromLoadingStateError(),
2935
+ * valueFromFinishedLoadingState()
2936
+ * )
2937
+ * );
2938
+ * ```
2939
+ *
2940
+ * @returns An `OperatorFunction` that passes through non-error states and throws on error states.
2854
2941
  */ function throwErrorFromLoadingStateError() {
2855
2942
  return function(obs) {
2856
2943
  return obs.pipe(rxjs.map(function(x) {
@@ -2990,12 +3077,30 @@ function distinctLoadingState(inputConfig) {
2990
3077
  };
2991
3078
  }
2992
3079
  /**
2993
- * Creates a promise from a Observable that pipes loading states that resolves the value when the loading state has finished loading.
3080
+ * Creates a Promise from an Observable of {@link LoadingState} that resolves when loading finishes.
2994
3081
  *
2995
- * If the loading state returns an error, the error is thrown.
3082
+ * Waits for the first finished loading state, then resolves with the value. If the finished state
3083
+ * contains an error, the promise is rejected with that error.
2996
3084
  *
2997
- * @param obs
2998
- * @returns
3085
+ * @example
3086
+ * ```ts
3087
+ * // Await a loading state observable as a promise
3088
+ * const value = await promiseFromLoadingState(dataState$);
3089
+ *
3090
+ * // Use within a work instance to forward errors
3091
+ * const result = await promiseFromLoadingState(
3092
+ * loadingStateObs.pipe(
3093
+ * filterMaybe(),
3094
+ * tap(() => this._setWorking(true))
3095
+ * )
3096
+ * ).catch((e) => {
3097
+ * this.reject(e);
3098
+ * throw e;
3099
+ * });
3100
+ * ```
3101
+ *
3102
+ * @param obs - The observable emitting {@link LoadingState} values.
3103
+ * @returns A Promise that resolves with the value or rejects with the error.
2999
3104
  */ function promiseFromLoadingState(obs) {
3000
3105
  return rxjs.firstValueFrom(obs.pipe(rxjs.filter(isLoadingStateFinishedLoading))).then(function(x) {
3001
3106
  var result;
package/index.cjs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/index.esm.js CHANGED
@@ -2751,9 +2751,25 @@ function _unsupported_iterable_to_array$3(o, minLen) {
2751
2751
  }
2752
2752
  // TODO(BREAKING_CHANGE): Fix all LoadingState types to use the LoadingStateValue inference typings
2753
2753
  /**
2754
- * Wraps an observable output and maps the value to a LoadingState.
2754
+ * Wraps an observable output and maps the value to a {@link LoadingState}.
2755
+ *
2756
+ * Emits a loading state immediately, then emits a success result when the observable emits a value,
2757
+ * or an error result if the observable errors.
2755
2758
  *
2756
2759
  * If firstOnly is provided, it will only take the first value the observable returns.
2760
+ *
2761
+ * @example
2762
+ * ```ts
2763
+ * // Wrap a data fetch observable into a LoadingState
2764
+ * readonly jsonContentState$ = loadingStateFromObs(this.jsonContent$);
2765
+ *
2766
+ * // Wrap an observable and only take the first emitted value
2767
+ * readonly singleValueState$ = loadingStateFromObs(this.data$, true);
2768
+ * ```
2769
+ *
2770
+ * @param obs - The source observable to wrap.
2771
+ * @param firstOnly - If true, only takes the first value from the observable.
2772
+ * @returns An observable that emits {@link LoadingState} values representing the loading lifecycle.
2757
2773
  */ function loadingStateFromObs(obs, firstOnly) {
2758
2774
  if (firstOnly) {
2759
2775
  obs = obs.pipe(first());
@@ -2790,10 +2806,27 @@ function combineLoadingStates() {
2790
2806
  );
2791
2807
  }
2792
2808
  /**
2793
- * Combines the status of all loading states. Only emits when the LoadingStateType of the result changes, or the loading state progress.
2809
+ * Combines the status of all loading states into a single {@link LoadingState}<boolean>.
2794
2810
  *
2795
- * @param sources
2796
- * @returns
2811
+ * Only emits when the {@link LoadingStateType} of the result changes, or the loading state progress changes.
2812
+ * If any source has an error, the error is propagated. If any source is still loading, the result is loading.
2813
+ * When all sources are successful, the result value is `true`.
2814
+ *
2815
+ * @example
2816
+ * ```ts
2817
+ * const success$ = of(successResult(1));
2818
+ * const success2$ = of(successResult(2));
2819
+ *
2820
+ * // All success => emits { value: true }
2821
+ * const status$ = combineLoadingStatesStatus([success$, success2$]);
2822
+ *
2823
+ * // One loading => emits loading state
2824
+ * const loading$ = of(beginLoading());
2825
+ * const status$ = combineLoadingStatesStatus([loading$, success$]);
2826
+ * ```
2827
+ *
2828
+ * @param sources - An array of LoadingState observables to combine.
2829
+ * @returns An observable emitting a {@link LoadingState}<boolean> representing the combined status.
2797
2830
  */ function combineLoadingStatesStatus(sources) {
2798
2831
  return combineLatest(sources).pipe(map(function(allLoadingStates) {
2799
2832
  var firstErrorState = allLoadingStates.find(function(x) {
@@ -2819,7 +2852,20 @@ function startWithBeginLoading(state) {
2819
2852
  return startWith(beginLoading(state));
2820
2853
  }
2821
2854
  /**
2822
- * Returns the current value from the LoadingState.
2855
+ * Returns the current value from the {@link LoadingState}, including `undefined` when still loading or no value is set.
2856
+ *
2857
+ * Unlike {@link valueFromLoadingState}, this operator emits for every state change, regardless of whether the value is defined.
2858
+ *
2859
+ * @example
2860
+ * ```ts
2861
+ * // Expose the current (possibly undefined) value from a loading state
2862
+ * const currentValue$: Observable<Maybe<T>> = state$.pipe(
2863
+ * currentValueFromLoadingState(),
2864
+ * shareReplay(1)
2865
+ * );
2866
+ * ```
2867
+ *
2868
+ * @returns An `OperatorFunction` that maps each {@link LoadingState} to its current value (or undefined).
2823
2869
  */ function currentValueFromLoadingState() {
2824
2870
  return function(obs) {
2825
2871
  return obs.pipe(map(function(x) {
@@ -2828,9 +2874,21 @@ function startWithBeginLoading(state) {
2828
2874
  };
2829
2875
  }
2830
2876
  /**
2831
- * Returns the current non-null value from the LoadingState.
2877
+ * Returns the current non-null/non-undefined value from the {@link LoadingState}.
2832
2878
  *
2833
- * Equivalent to currentValueFromLoadingState() and filterMaybe().
2879
+ * Equivalent to piping {@link currentValueFromLoadingState} and `filterMaybeStrict()`.
2880
+ * Only emits when the value is defined, filtering out loading and error states without values.
2881
+ *
2882
+ * @example
2883
+ * ```ts
2884
+ * // Only emit when the loading state has a defined value
2885
+ * const value$ = state$.pipe(
2886
+ * valueFromLoadingState(),
2887
+ * // only emits non-null/non-undefined values
2888
+ * );
2889
+ * ```
2890
+ *
2891
+ * @returns An `OperatorFunction` that emits only defined values from the {@link LoadingState}.
2834
2892
  */ function valueFromLoadingState() {
2835
2893
  return function(obs) {
2836
2894
  return obs.pipe(map(function(x) {
@@ -2839,7 +2897,20 @@ function startWithBeginLoading(state) {
2839
2897
  };
2840
2898
  }
2841
2899
  /**
2842
- * Returns the error once the LoadingState has finished loading with an error.
2900
+ * Returns the error once the {@link LoadingState} has finished loading with an error.
2901
+ *
2902
+ * Filters to only emit when the state contains an error, then extracts and emits the {@link ReadableError}.
2903
+ *
2904
+ * @example
2905
+ * ```ts
2906
+ * // React to errors from a loading state
2907
+ * state$.pipe(
2908
+ * errorFromLoadingState(),
2909
+ * tap((error) => console.error('Loading failed:', error))
2910
+ * ).subscribe();
2911
+ * ```
2912
+ *
2913
+ * @returns An `OperatorFunction` that emits the {@link ReadableError} from error states.
2843
2914
  */ function errorFromLoadingState() {
2844
2915
  return function(obs) {
2845
2916
  return obs.pipe(filter(isLoadingStateWithError), map(function(x) {
@@ -2848,7 +2919,23 @@ function startWithBeginLoading(state) {
2848
2919
  };
2849
2920
  }
2850
2921
  /**
2851
- * Throws an error if the LoadingState value has an error.
2922
+ * Throws an error if the {@link LoadingState} value has an error.
2923
+ *
2924
+ * Passes through non-error states unchanged, but throws the error from any {@link LoadingStateWithError},
2925
+ * converting the loading state error into an observable error that can be caught with `catchError`.
2926
+ *
2927
+ * @example
2928
+ * ```ts
2929
+ * // Convert a LoadingState observable to a Promise, throwing on error states
2930
+ * const result = await firstValueFrom(
2931
+ * loadingState$.pipe(
2932
+ * throwErrorFromLoadingStateError(),
2933
+ * valueFromFinishedLoadingState()
2934
+ * )
2935
+ * );
2936
+ * ```
2937
+ *
2938
+ * @returns An `OperatorFunction` that passes through non-error states and throws on error states.
2852
2939
  */ function throwErrorFromLoadingStateError() {
2853
2940
  return function(obs) {
2854
2941
  return obs.pipe(map(function(x) {
@@ -2988,12 +3075,30 @@ function distinctLoadingState(inputConfig) {
2988
3075
  };
2989
3076
  }
2990
3077
  /**
2991
- * Creates a promise from a Observable that pipes loading states that resolves the value when the loading state has finished loading.
3078
+ * Creates a Promise from an Observable of {@link LoadingState} that resolves when loading finishes.
2992
3079
  *
2993
- * If the loading state returns an error, the error is thrown.
3080
+ * Waits for the first finished loading state, then resolves with the value. If the finished state
3081
+ * contains an error, the promise is rejected with that error.
2994
3082
  *
2995
- * @param obs
2996
- * @returns
3083
+ * @example
3084
+ * ```ts
3085
+ * // Await a loading state observable as a promise
3086
+ * const value = await promiseFromLoadingState(dataState$);
3087
+ *
3088
+ * // Use within a work instance to forward errors
3089
+ * const result = await promiseFromLoadingState(
3090
+ * loadingStateObs.pipe(
3091
+ * filterMaybe(),
3092
+ * tap(() => this._setWorking(true))
3093
+ * )
3094
+ * ).catch((e) => {
3095
+ * this.reject(e);
3096
+ * throw e;
3097
+ * });
3098
+ * ```
3099
+ *
3100
+ * @param obs - The observable emitting {@link LoadingState} values.
3101
+ * @returns A Promise that resolves with the value or rejects with the error.
2997
3102
  */ function promiseFromLoadingState(obs) {
2998
3103
  return firstValueFrom(obs.pipe(filter(isLoadingStateFinishedLoading))).then(function(x) {
2999
3104
  var result;
package/index.esm.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dereekb/rxjs",
3
- "version": "13.0.4",
3
+ "version": "13.0.6",
4
4
  "peerDependencies": {
5
5
  "rxjs": "^7.8.0",
6
- "@dereekb/util": "13.0.4"
6
+ "@dereekb/util": "13.0.6"
7
7
  },
8
8
  "exports": {
9
9
  "./package.json": "./package.json",
@@ -2,13 +2,54 @@ import { type Maybe, type ReadableError, type EqualityComparatorFunction, type G
2
2
  import { type MonoTypeOperatorFunction, type OperatorFunction, type Observable, type ObservableInputTuple } from 'rxjs';
3
3
  import { type LoadingState, type PageLoadingState, type MapLoadingStateResultsConfiguration, type LoadingStateValue, LoadingStateType, type LoadingStateWithValueType, type LoadingStateWithDefinedValue, type LoadingStateWithError } from './loading.state';
4
4
  /**
5
- * Wraps an observable output and maps the value to a LoadingState.
5
+ * Wraps an observable output and maps the value to a {@link LoadingState}.
6
+ *
7
+ * Emits a loading state immediately, then emits a success result when the observable emits a value,
8
+ * or an error result if the observable errors.
6
9
  *
7
10
  * If firstOnly is provided, it will only take the first value the observable returns.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // Wrap a data fetch observable into a LoadingState
15
+ * readonly jsonContentState$ = loadingStateFromObs(this.jsonContent$);
16
+ *
17
+ * // Wrap an observable and only take the first emitted value
18
+ * readonly singleValueState$ = loadingStateFromObs(this.data$, true);
19
+ * ```
20
+ *
21
+ * @param obs - The source observable to wrap.
22
+ * @param firstOnly - If true, only takes the first value from the observable.
23
+ * @returns An observable that emits {@link LoadingState} values representing the loading lifecycle.
8
24
  */
9
25
  export declare function loadingStateFromObs<T>(obs: Observable<T>, firstOnly?: boolean): Observable<LoadingState<T>>;
10
26
  /**
11
- * Convenience function for creating a pipe that merges the multiple loading states into one.
27
+ * Convenience function for creating a pipe that merges multiple loading states into one.
28
+ *
29
+ * Combines two or more {@link LoadingState} observables using `combineLatest` and merges their values.
30
+ * If any input is still loading, the combined state is loading. If any input has an error, the error is propagated.
31
+ * An optional merge function can be provided to customize how the values are combined; otherwise, values are spread-merged.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // Merge two loading states into one combined state using object spread
36
+ * const combined$ = combineLoadingStates(
37
+ * of(successResult({ a: true })),
38
+ * of(successResult({ b: true }))
39
+ * );
40
+ * // => emits LoadingState<{ a: true } & { b: true }>
41
+ *
42
+ * // Merge with a custom merge function
43
+ * const combined$ = combineLoadingStates(
44
+ * of(successResult({ a: 1 })),
45
+ * of(successResult({ b: 2 })),
46
+ * (a, b) => ({ sum: a.a + b.b })
47
+ * );
48
+ * // => emits LoadingState<{ sum: number }> with value { sum: 3 }
49
+ * ```
50
+ *
51
+ * @param args - Two or more LoadingState observables, with an optional merge function as the last argument.
52
+ * @returns An observable emitting the merged {@link LoadingState}.
12
53
  */
13
54
  export declare function combineLoadingStates<A, B>(obsA: Observable<LoadingState<A>>, obsB: Observable<LoadingState<B>>): Observable<LoadingState<A & B>>;
14
55
  export declare function combineLoadingStates<A extends object, B extends object, O>(obsA: Observable<LoadingState<A>>, obsB: Observable<LoadingState<B>>, mergeFn: (a: A, b: B) => O): Observable<LoadingState<O>>;
@@ -20,82 +61,289 @@ export declare function combineLoadingStates<A extends object, B extends object,
20
61
  export declare function combineLoadingStates<A extends object, B extends object, C extends object, D extends object, E extends object, O>(obsA: Observable<LoadingState<A>>, obsB: Observable<LoadingState<B>>, obsC: Observable<LoadingState<C>>, obsD: Observable<LoadingState<D>>, obsE: Observable<LoadingState<E>>, mergeFn: (a: A, b: B, c: C, d: D, e: E) => O): Observable<LoadingState<O>>;
21
62
  export declare function combineLoadingStates<O>(...args: any[]): Observable<LoadingState<O>>;
22
63
  /**
23
- * Combines the status of all loading states. Only emits when the LoadingStateType of the result changes, or the loading state progress.
64
+ * Combines the status of all loading states into a single {@link LoadingState}<boolean>.
65
+ *
66
+ * Only emits when the {@link LoadingStateType} of the result changes, or the loading state progress changes.
67
+ * If any source has an error, the error is propagated. If any source is still loading, the result is loading.
68
+ * When all sources are successful, the result value is `true`.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const success$ = of(successResult(1));
73
+ * const success2$ = of(successResult(2));
24
74
  *
25
- * @param sources
26
- * @returns
75
+ * // All success => emits { value: true }
76
+ * const status$ = combineLoadingStatesStatus([success$, success2$]);
77
+ *
78
+ * // One loading => emits loading state
79
+ * const loading$ = of(beginLoading());
80
+ * const status$ = combineLoadingStatesStatus([loading$, success$]);
81
+ * ```
82
+ *
83
+ * @param sources - An array of LoadingState observables to combine.
84
+ * @returns An observable emitting a {@link LoadingState}<boolean> representing the combined status.
27
85
  */
28
86
  export declare function combineLoadingStatesStatus<A extends readonly LoadingState<any>[]>(sources: readonly [...ObservableInputTuple<A>]): Observable<LoadingState<boolean>>;
29
87
  /**
30
- * Merges startWith() with beginLoading().
88
+ * Merges `startWith()` with `beginLoading()` into a single typed operator.
89
+ *
90
+ * Preferred over using both individually, as typing information can get lost when chaining them separately.
91
+ * An optional partial state can be provided to include additional metadata (e.g., page info) in the initial loading state.
31
92
  *
32
- * Preferred over using both individually, as typing information can get lost.
93
+ * @example
94
+ * ```ts
95
+ * // Emit a loading state immediately before the source observable emits
96
+ * readonly resultsState$ = this.fetchValues().pipe(
97
+ * map((values) => successResult(values)),
98
+ * startWithBeginLoading(),
99
+ * shareReplay(1)
100
+ * );
33
101
  *
34
- * @returns
102
+ * // Use inside a switchMap to re-emit loading on each new search
103
+ * readonly searchResultsState$ = this.searchText$.pipe(
104
+ * switchMap((text) =>
105
+ * this.search(text).pipe(
106
+ * startWithBeginLoading()
107
+ * )
108
+ * ),
109
+ * shareReplay(1)
110
+ * );
111
+ * ```
112
+ *
113
+ * @param state - Optional partial loading state to include in the initial emission.
114
+ * @returns A `MonoTypeOperatorFunction` that prepends a loading state to the observable.
35
115
  */
36
116
  export declare function startWithBeginLoading<L extends LoadingState>(): MonoTypeOperatorFunction<L>;
37
117
  export declare function startWithBeginLoading<L extends LoadingState>(state?: Partial<LoadingState>): MonoTypeOperatorFunction<L>;
38
118
  export declare function startWithBeginLoading<L extends PageLoadingState>(state?: Partial<PageLoadingState>): MonoTypeOperatorFunction<L>;
39
119
  /**
40
- * Returns the current value from the LoadingState.
120
+ * Returns the current value from the {@link LoadingState}, including `undefined` when still loading or no value is set.
121
+ *
122
+ * Unlike {@link valueFromLoadingState}, this operator emits for every state change, regardless of whether the value is defined.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * // Expose the current (possibly undefined) value from a loading state
127
+ * const currentValue$: Observable<Maybe<T>> = state$.pipe(
128
+ * currentValueFromLoadingState(),
129
+ * shareReplay(1)
130
+ * );
131
+ * ```
132
+ *
133
+ * @returns An `OperatorFunction` that maps each {@link LoadingState} to its current value (or undefined).
41
134
  */
42
135
  export declare function currentValueFromLoadingState<L extends LoadingState>(): OperatorFunction<L, Maybe<LoadingStateValue<L>>>;
43
136
  /**
44
- * Returns the current non-null value from the LoadingState.
137
+ * Returns the current non-null/non-undefined value from the {@link LoadingState}.
45
138
  *
46
- * Equivalent to currentValueFromLoadingState() and filterMaybe().
139
+ * Equivalent to piping {@link currentValueFromLoadingState} and `filterMaybeStrict()`.
140
+ * Only emits when the value is defined, filtering out loading and error states without values.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * // Only emit when the loading state has a defined value
145
+ * const value$ = state$.pipe(
146
+ * valueFromLoadingState(),
147
+ * // only emits non-null/non-undefined values
148
+ * );
149
+ * ```
150
+ *
151
+ * @returns An `OperatorFunction` that emits only defined values from the {@link LoadingState}.
47
152
  */
48
153
  export declare function valueFromLoadingState<L extends LoadingStateWithDefinedValue>(): OperatorFunction<L, MaybeSoStrict<LoadingStateValue<L>>>;
49
154
  /**
50
- * Returns the error once the LoadingState has finished loading with an error.
155
+ * Returns the error once the {@link LoadingState} has finished loading with an error.
156
+ *
157
+ * Filters to only emit when the state contains an error, then extracts and emits the {@link ReadableError}.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * // React to errors from a loading state
162
+ * state$.pipe(
163
+ * errorFromLoadingState(),
164
+ * tap((error) => console.error('Loading failed:', error))
165
+ * ).subscribe();
166
+ * ```
167
+ *
168
+ * @returns An `OperatorFunction` that emits the {@link ReadableError} from error states.
51
169
  */
52
170
  export declare function errorFromLoadingState<L extends LoadingState>(): OperatorFunction<L, ReadableError>;
53
171
  /**
54
- * Throws an error if the LoadingState value has an error.
172
+ * Throws an error if the {@link LoadingState} value has an error.
173
+ *
174
+ * Passes through non-error states unchanged, but throws the error from any {@link LoadingStateWithError},
175
+ * converting the loading state error into an observable error that can be caught with `catchError`.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * // Convert a LoadingState observable to a Promise, throwing on error states
180
+ * const result = await firstValueFrom(
181
+ * loadingState$.pipe(
182
+ * throwErrorFromLoadingStateError(),
183
+ * valueFromFinishedLoadingState()
184
+ * )
185
+ * );
186
+ * ```
187
+ *
188
+ * @returns An `OperatorFunction` that passes through non-error states and throws on error states.
55
189
  */
56
190
  export declare function throwErrorFromLoadingStateError<L extends LoadingState>(): OperatorFunction<L, L>;
57
191
  /**
58
- * Returns the value once the LoadingState has finished loading, even if an error occured or there is no value.
192
+ * Returns the value once the {@link LoadingState} has finished loading, even if an error occurred or there is no value.
193
+ *
194
+ * Filters to only emit when loading is complete, then maps to the value. A default value (or getter) can be
195
+ * provided to use when the finished state has no value (e.g., due to an error).
59
196
  *
60
- * Can optionally specify a default value to use instead.
197
+ * @example
198
+ * ```ts
199
+ * // Wait for loading to complete and emit the value
200
+ * const value$ = state$.pipe(
201
+ * valueFromFinishedLoadingState(),
202
+ * shareReplay(1)
203
+ * );
204
+ *
205
+ * // Provide a default value for error/empty states
206
+ * const items$ = itemsState$.pipe(
207
+ * valueFromFinishedLoadingState(() => []),
208
+ * shareReplay(1)
209
+ * );
210
+ * ```
211
+ *
212
+ * @param defaultValue - Optional default value or getter to use when the finished state has no value.
213
+ * @returns An `OperatorFunction` that emits the value (or default) once loading is finished.
61
214
  */
62
215
  export declare function valueFromFinishedLoadingState<L extends LoadingState>(defaultValue: GetterOrValue<LoadingStateValue<L>>): OperatorFunction<L, LoadingStateValue<L>>;
63
216
  export declare function valueFromFinishedLoadingState<L extends LoadingState>(defaultValue?: Maybe<GetterOrValue<LoadingStateValue<L>>>): OperatorFunction<L, Maybe<LoadingStateValue<L>>>;
64
217
  export declare function valueFromFinishedLoadingState<L extends LoadingStateWithDefinedValue>(): OperatorFunction<L, LoadingStateValue<L>>;
65
218
  /**
66
- * Executes a function when the piped LoadingState has the configured state.
219
+ * Executes a side-effect function when the piped {@link LoadingState} matches the given {@link LoadingStateType}.
220
+ *
221
+ * This is a tap-style operator that does not modify the stream, but calls `fn` when the state matches the specified type.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * // Log whenever the state transitions to an error
226
+ * state$.pipe(
227
+ * tapOnLoadingStateType((state) => console.error('Error:', state.error), LoadingStateType.ERROR)
228
+ * ).subscribe();
67
229
  *
68
- * @param fn
230
+ * // Trigger an action when loading begins
231
+ * state$.pipe(
232
+ * tapOnLoadingStateType(() => showSpinner(), LoadingStateType.LOADING)
233
+ * ).subscribe();
234
+ * ```
235
+ *
236
+ * @param fn - The side-effect function to call when the state matches.
237
+ * @param type - The {@link LoadingStateType} to match against.
238
+ * @returns A `MonoTypeOperatorFunction` that taps on matching states.
69
239
  */
70
240
  export declare function tapOnLoadingStateType<L extends LoadingState>(fn: (state: L) => void, type: LoadingStateType): MonoTypeOperatorFunction<L>;
71
241
  export declare function tapOnLoadingStateType<L extends LoadingState>(fn: (state: L) => void, type: LoadingStateType): MonoTypeOperatorFunction<L>;
72
242
  export declare function tapOnLoadingStateType<L extends PageLoadingState>(fn: (state: L) => void, type: LoadingStateType): MonoTypeOperatorFunction<L>;
73
243
  /**
74
- * Executes a function when the input state has a successful value.
244
+ * Executes a side-effect function when the input {@link LoadingState} has a successful value.
245
+ *
246
+ * This is a convenience wrapper around {@link tapOnLoadingStateType} with {@link LoadingStateType.SUCCESS}.
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * // Log the successful value
251
+ * state$.pipe(
252
+ * tapOnLoadingStateSuccess((state) => console.log('Loaded:', state.value))
253
+ * ).subscribe();
254
+ * ```
75
255
  *
76
- * @param fn
256
+ * @param fn - The side-effect function to call on success states.
257
+ * @returns A `MonoTypeOperatorFunction` that taps on successful states.
77
258
  */
78
259
  export declare function tapOnLoadingStateSuccess<L extends LoadingState>(fn: (state: L) => void): MonoTypeOperatorFunction<L>;
79
260
  export declare function tapOnLoadingStateSuccess<L extends LoadingState>(fn: (state: L) => void): MonoTypeOperatorFunction<L>;
80
261
  export declare function tapOnLoadingStateSuccess<L extends PageLoadingState>(fn: (state: L) => void): MonoTypeOperatorFunction<L>;
81
262
  /**
82
- * Convenience function for using mapLoadingStateResults with an Observable.
263
+ * Convenience function for using {@link mapLoadingStateResults} with an Observable.
264
+ *
265
+ * Maps the value within a {@link LoadingState} using the provided configuration, preserving the loading/error state metadata.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * // Map a SystemState<T> loading state to just its data property
270
+ * readonly dataState$: Observable<LoadingState<T>> = this.systemStateLoadingState$.pipe(
271
+ * mapLoadingState({ mapValue: (x: SystemState<T>) => x.data }),
272
+ * shareReplay(1)
273
+ * );
274
+ * ```
275
+ *
276
+ * @param config - Configuration for mapping the loading state value.
277
+ * @returns An `OperatorFunction` that maps the value within the loading state.
83
278
  */
84
279
  export declare function mapLoadingState<A, B, L extends LoadingState<A> = LoadingState<A>, O extends LoadingState<B> = LoadingState<B>>(config: MapLoadingStateResultsConfiguration<A, B, L, O>): OperatorFunction<L, O>;
85
280
  export declare function mapLoadingState<A, B, L extends PageLoadingState<A> = PageLoadingState<A>, O extends PageLoadingState<B> = PageLoadingState<B>>(config: MapLoadingStateResultsConfiguration<A, B, L, O>): OperatorFunction<L, O>;
86
281
  export declare function mapLoadingState<A, B, L extends Partial<PageLoadingState<A>> = Partial<PageLoadingState<A>>, O extends Partial<PageLoadingState<B>> = Partial<PageLoadingState<B>>>(config: MapLoadingStateResultsConfiguration<A, B, L, O>): OperatorFunction<L, O>;
87
282
  /**
88
- * Convenience function for catching the loading state's error from one value to another using an arbitrary operator.
283
+ * Maps the value within a {@link LoadingState} using an arbitrary RxJS operator.
284
+ *
285
+ * When the state has a defined value, the value is extracted, passed through the provided operator,
286
+ * and the result is wrapped back into the loading state. If the operator does not emit immediately,
287
+ * a temporary loading state (with no value) is emitted while waiting.
288
+ *
289
+ * Error and loading states are passed through without invoking the operator.
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * // Filter loading state values using a search string operator
294
+ * readonly state$: Observable<ListLoadingState<DocValue>> = this._values.pipe(
295
+ * switchMap((x) => of(successResult(x)).pipe(startWithBeginLoading())),
296
+ * mapLoadingStateValueWithOperator(
297
+ * filterWithSearchString({
298
+ * filter: (a) => a.name,
299
+ * search$: this.search$
300
+ * })
301
+ * )
302
+ * );
303
+ *
304
+ * // Transform values using switchMap inside the operator
305
+ * readonly groupsState$ = this.itemsState$.pipe(
306
+ * mapLoadingStateValueWithOperator(
307
+ * switchMap((items) => this.viewDelegate$.pipe(
308
+ * switchMap((delegate) => asObservable(delegate.groupBy(items)))
309
+ * ))
310
+ * ),
311
+ * shareReplay(1)
312
+ * );
313
+ * ```
314
+ *
315
+ * @param operator - The RxJS operator to apply to the loading state's value.
316
+ * @param mapOnUndefined - If true, also applies the operator when the value is undefined (but loading is finished and no error).
317
+ * @returns An `OperatorFunction` that transforms the value within the loading state.
89
318
  */
90
319
  export declare function mapLoadingStateValueWithOperator<L extends LoadingState, O>(operator: OperatorFunction<LoadingStateValue<L>, O>, mapOnUndefined?: boolean): OperatorFunction<L, LoadingStateWithValueType<L, O>>;
91
320
  export declare function mapLoadingStateValueWithOperator<L extends PageLoadingState, O>(operator: OperatorFunction<LoadingStateValue<L>, O>, mapOnUndefined?: boolean): OperatorFunction<L, LoadingStateWithValueType<L, O>>;
92
321
  export declare function mapLoadingStateValueWithOperator<L extends Partial<PageLoadingState>, O>(operator: OperatorFunction<LoadingStateValue<L>, O>, mapOnUndefined?: boolean): OperatorFunction<L, LoadingStateWithValueType<L, O>>;
93
322
  /**
94
- * Convenience function for catching an LoadingStateWithError and returning a new LoadingState.
323
+ * Catches a {@link LoadingStateWithError} and transforms it into a new {@link LoadingState} using the provided operator.
324
+ *
325
+ * Non-error states are passed through unchanged. When an error state is encountered, it is passed through the
326
+ * operator to produce a replacement state. If the operator does not emit immediately, a temporary loading state is emitted.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * // On error, return an empty list instead of propagating the error
331
+ * readonly notificationItemsLoadingState$ = this.store.notificationItemsLoadingState$.pipe(
332
+ * catchLoadingStateErrorWithOperator<LoadingState<NotificationItem<any>[]>>(
333
+ * map(() => successResult([]))
334
+ * )
335
+ * );
336
+ * ```
337
+ *
338
+ * @param operator - The RxJS operator to apply to the error loading state.
339
+ * @returns A `MonoTypeOperatorFunction` that catches and transforms error states.
95
340
  */
96
341
  export declare function catchLoadingStateErrorWithOperator<L extends LoadingState>(operator: OperatorFunction<L & LoadingStateWithError, L>): MonoTypeOperatorFunction<L>;
97
342
  export declare function catchLoadingStateErrorWithOperator<L extends PageLoadingState>(operator: OperatorFunction<L & LoadingStateWithError, L>): MonoTypeOperatorFunction<L>;
98
343
  export declare function catchLoadingStateErrorWithOperator<L extends Partial<PageLoadingState>>(operator: OperatorFunction<L & LoadingStateWithError, L>): MonoTypeOperatorFunction<L>;
344
+ /**
345
+ * Config for {@link distinctLoadingState}.
346
+ */
99
347
  export interface DistinctLoadingStateConfig<L extends LoadingState> {
100
348
  /**
101
349
  * Whether or not to pass the retained value when the next LoadingState's value (the value being considered by this DecisionFunction) is null/undefined.
@@ -117,23 +365,60 @@ export interface DistinctLoadingStateConfig<L extends LoadingState> {
117
365
  metadataComparator?: EqualityComparatorFunction<Maybe<Partial<L>>>;
118
366
  }
119
367
  /**
120
- * A special distinctUntilChanged-like operator for LoadingState and PageLoadingState.
368
+ * A special `distinctUntilChanged`-like operator for {@link LoadingState} and {@link PageLoadingState}.
369
+ *
370
+ * Retains the previous value and only emits when the value or loading state metadata actually changes,
371
+ * as determined by the provided value comparator. This prevents unnecessary re-emissions when a loading
372
+ * state re-emits with an equivalent value.
373
+ *
374
+ * Accepts either a simple {@link EqualityComparatorFunction} for comparing values, or a full
375
+ * {@link DistinctLoadingStateConfig} for more fine-grained control over comparison behavior.
121
376
  *
122
- * It saves the previous value and passes it through whenever the LoadingState changes.
377
+ * @example
378
+ * ```ts
379
+ * // Filter out duplicate loading states using key-based comparison
380
+ * const distinct$ = values$.pipe(
381
+ * distinctLoadingState(objectKeysEqualityComparatorFunction((x) => x))
382
+ * );
123
383
  *
124
- * @param operator
125
- * @param mapOnUndefined
126
- * @returns
384
+ * // Full config with custom comparator
385
+ * const distinct$ = values$.pipe(
386
+ * distinctLoadingState({
387
+ * valueComparator: (a, b) => a?.id === b?.id,
388
+ * })
389
+ * );
390
+ * ```
391
+ *
392
+ * @param config - Either a value comparator function or a full {@link DistinctLoadingStateConfig}.
393
+ * @returns A `MonoTypeOperatorFunction` that filters out duplicate loading states.
127
394
  */
128
395
  export declare function distinctLoadingState<L extends LoadingState>(config: EqualityComparatorFunction<Maybe<LoadingStateValue<L>>> | DistinctLoadingStateConfig<L>): MonoTypeOperatorFunction<L>;
129
396
  export declare function distinctLoadingState<L extends PageLoadingState>(config: EqualityComparatorFunction<Maybe<LoadingStateValue<L>>> | DistinctLoadingStateConfig<L>): MonoTypeOperatorFunction<L>;
130
397
  export declare function distinctLoadingState<L extends Partial<PageLoadingState>>(config: EqualityComparatorFunction<Maybe<LoadingStateValue<L>>> | DistinctLoadingStateConfig<L>): MonoTypeOperatorFunction<L>;
131
398
  /**
132
- * Creates a promise from a Observable that pipes loading states that resolves the value when the loading state has finished loading.
399
+ * Creates a Promise from an Observable of {@link LoadingState} that resolves when loading finishes.
400
+ *
401
+ * Waits for the first finished loading state, then resolves with the value. If the finished state
402
+ * contains an error, the promise is rejected with that error.
403
+ *
404
+ * @example
405
+ * ```ts
406
+ * // Await a loading state observable as a promise
407
+ * const value = await promiseFromLoadingState(dataState$);
133
408
  *
134
- * If the loading state returns an error, the error is thrown.
409
+ * // Use within a work instance to forward errors
410
+ * const result = await promiseFromLoadingState(
411
+ * loadingStateObs.pipe(
412
+ * filterMaybe(),
413
+ * tap(() => this._setWorking(true))
414
+ * )
415
+ * ).catch((e) => {
416
+ * this.reject(e);
417
+ * throw e;
418
+ * });
419
+ * ```
135
420
  *
136
- * @param obs
137
- * @returns
421
+ * @param obs - The observable emitting {@link LoadingState} values.
422
+ * @returns A Promise that resolves with the value or rejects with the error.
138
423
  */
139
424
  export declare function promiseFromLoadingState<T>(obs: Observable<LoadingState<T>>): Promise<T>;