@dereekb/rxjs 13.3.1 → 13.4.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.
@@ -1,5 +1,5 @@
1
1
  import { type MonoTypeOperatorFunction, type Observable, type OperatorFunction } from 'rxjs';
2
- import { type DecisionFunction, type GetterOrValue, type MapFunction, type Maybe, type MaybeSoStrict } from '@dereekb/util';
2
+ import { type DecisionFunction, type GetterOrValue, type MapFunction, type Maybe, type Milliseconds, type MaybeSoStrict } from '@dereekb/util';
3
3
  import { type MaybeObservableOrValueGetter, type ObservableOrValueGetter, type MaybeObservableOrValue } from './getter';
4
4
  import { type ObservableDecisionFunction } from './decision';
5
5
  /**
@@ -59,6 +59,7 @@ export declare function makeIsModifiedFunctionObservable<T>(config: MakeIsModifi
59
59
  *
60
60
  * @param isCheckFunction - optional check function
61
61
  * @param defaultValueOnMaybe - default result for null/undefined values
62
+ * @returns a function that evaluates each value against the check function and returns it or undefined
62
63
  */
63
64
  export declare function makeReturnIfIsFunction<T>(isCheckFunction: Maybe<IsModifiedFunction<T>>, defaultValueOnMaybe?: boolean): (value: Maybe<T>) => Observable<Maybe<T>>;
64
65
  /**
@@ -67,6 +68,7 @@ export declare function makeReturnIfIsFunction<T>(isCheckFunction: Maybe<IsModif
67
68
  * @param isCheckFunction - optional check function
68
69
  * @param value - the value to check
69
70
  * @param defaultValueOnMaybe - default result for null/undefined values
71
+ * @returns an observable that emits the value if the check passes, or undefined otherwise
70
72
  */
71
73
  export declare function returnIfIs<T>(isCheckFunction: Maybe<IsModifiedFunction<T>>, value: Maybe<T>, defaultValueOnMaybe?: boolean): Observable<Maybe<T>>;
72
74
  /**
@@ -74,6 +76,7 @@ export declare function returnIfIs<T>(isCheckFunction: Maybe<IsModifiedFunction<
74
76
  *
75
77
  * @param isCheckFunction - optional check function
76
78
  * @param defaultValueOnMaybe - default result for null/undefined values
79
+ * @returns a function that evaluates each value against the check function and returns an observable boolean
77
80
  */
78
81
  export declare function makeCheckIsFunction<T>(isCheckFunction: Maybe<IsModifiedFunction<T>>, defaultValueOnMaybe?: boolean): (value: Maybe<T>) => Observable<boolean>;
79
82
  /**
@@ -84,10 +87,13 @@ export declare function makeCheckIsFunction<T>(isCheckFunction: Maybe<IsModified
84
87
  * @param isCheckFunction - optional check function
85
88
  * @param value - the value to check
86
89
  * @param defaultValueOnMaybe - default result for null/undefined values (defaults to false)
90
+ * @returns an observable boolean indicating whether the value passes the check
87
91
  */
88
92
  export declare function checkIs<T>(isCheckFunction: Maybe<IsModifiedFunction<T>>, value: Maybe<T>, defaultValueOnMaybe?: boolean): Observable<boolean>;
89
93
  /**
90
94
  * RxJS operator that filters out null and undefined values, only passing through defined values.
95
+ *
96
+ * @returns operator that filters out null and undefined emissions
91
97
  */
92
98
  export declare function filterMaybe<T>(): OperatorFunction<Maybe<T>, T>;
93
99
  /**
@@ -96,20 +102,27 @@ export declare function filterMaybe<T>(): OperatorFunction<Maybe<T>, T>;
96
102
  export declare const filterMaybeStrict: <T>() => OperatorFunction<Maybe<T>, MaybeSoStrict<T>>;
97
103
  /**
98
104
  * RxJS operator that filters out null/undefined elements from an emitted array, keeping only defined values.
105
+ *
106
+ * @returns operator that maps each emitted array to a version with null/undefined elements removed
99
107
  */
100
108
  export declare function filterMaybeArray<T>(): OperatorFunction<Maybe<T>[], T[]>;
101
109
  /**
102
110
  * RxJS operator that skips all leading null/undefined emissions, then passes all subsequent values through.
111
+ *
112
+ * @returns operator that skips all null/undefined emissions at the start of the stream
103
113
  */
104
114
  export declare function skipAllInitialMaybe<T>(): MonoTypeOperatorFunction<T>;
105
115
  /**
106
116
  * RxJS operator that skips only the first emission if it is null/undefined, then passes all subsequent values.
117
+ *
118
+ * @returns operator that skips the first null/undefined emission if it occurs at the start of the stream
107
119
  */
108
120
  export declare function skipInitialMaybe<T>(): MonoTypeOperatorFunction<T>;
109
121
  /**
110
122
  * RxJS operator that skips up to `maxToSkip` null/undefined emissions, then passes all subsequent values.
111
123
  *
112
124
  * @param maxToSkip - maximum number of null/undefined emissions to skip
125
+ * @returns operator that skips the first N null/undefined emissions from the stream
113
126
  */
114
127
  export declare function skipMaybes<T>(maxToSkip: number): MonoTypeOperatorFunction<T>;
115
128
  /**
@@ -135,16 +148,22 @@ export declare function switchMapToDefault<T = unknown>(defaultObs: MaybeObserva
135
148
  export declare function switchMapToDefault<T = unknown>(defaultObs: ObservableOrValueGetter<T>): OperatorFunction<Maybe<T>, T>;
136
149
  export declare function switchMapToDefault<T = unknown>(defaultObs: MaybeObservableOrValueGetter<T>, useDefault?: SwitchMapToDefaultFilterFunction<T>): OperatorFunction<Maybe<T>, Maybe<T>>;
137
150
  export interface SwitchMapObjectConfig<T> {
138
- defaultGetter?: GetterOrValue<Maybe<T>>;
151
+ readonly defaultGetter?: GetterOrValue<Maybe<T>>;
139
152
  }
140
153
  /**
141
154
  * RxJS operator that resolves an observable/getter config input into a value, applying defaults
142
155
  * for `null`/`undefined`/`true` inputs and emitting `null` for `false`.
156
+ *
157
+ * @param config - configuration providing an optional default getter for null/undefined/true inputs
158
+ * @returns operator that resolves each emitted getter into a value, using the default for nullish or true inputs
143
159
  */
144
160
  export declare function switchMapObject<T extends object>(config: SwitchMapObjectConfig<T>): OperatorFunction<Maybe<ObservableOrValueGetter<Maybe<T | boolean>>>, Maybe<T>>;
145
161
  /**
146
162
  * RxJS operator that emits from the given observable/getter when the source boolean is `true`,
147
163
  * otherwise emits from the `otherwise` source or `EMPTY`.
164
+ *
165
+ * @param obs - observable or getter to subscribe to when the source emits `true`
166
+ * @returns operator that switches to the given source when the boolean is true
148
167
  */
149
168
  export declare function switchMapWhileTrue<T = unknown>(obs: ObservableOrValueGetter<T>): OperatorFunction<boolean, T>;
150
169
  export declare function switchMapWhileTrue<T = unknown>(obs: MaybeObservableOrValueGetter<T>): OperatorFunction<boolean, T>;
@@ -153,6 +172,9 @@ export declare function switchMapWhileTrue<T = unknown>(obs: MaybeObservableOrVa
153
172
  /**
154
173
  * RxJS operator that emits from the given observable/getter when the source boolean is `false`,
155
174
  * otherwise emits from the `otherwise` source or `EMPTY`.
175
+ *
176
+ * @param obs - observable or getter to subscribe to when the source emits `false`
177
+ * @returns operator that switches to the given source when the boolean is false
156
178
  */
157
179
  export declare function switchMapWhileFalse<T = unknown>(obs: ObservableOrValueGetter<T>): OperatorFunction<boolean, T>;
158
180
  export declare function switchMapWhileFalse<T = unknown>(obs: MaybeObservableOrValueGetter<T>): OperatorFunction<boolean, T>;
@@ -165,6 +187,7 @@ export declare function switchMapWhileFalse<T = unknown>(obs: MaybeObservableOrV
165
187
  * @param switchOnValue - the boolean value that triggers emitting from `obs`
166
188
  * @param obs - observable/getter to emit from when matched
167
189
  * @param otherwise - optional observable/getter for the non-matching case
190
+ * @returns operator that switches to the appropriate source based on the emitted boolean value
168
191
  */
169
192
  export declare function switchMapOnBoolean<T = unknown>(switchOnValue: boolean, obs: MaybeObservableOrValueGetter<T>): OperatorFunction<boolean, T>;
170
193
  export declare function switchMapOnBoolean<T = unknown>(switchOnValue: boolean, obs: MaybeObservableOrValueGetter<T>, otherwise?: MaybeObservableOrValueGetter<T>): OperatorFunction<boolean, Maybe<T>>;
@@ -172,10 +195,14 @@ export declare function switchMapOnBoolean<T = unknown>(switchOnValue: boolean,
172
195
  * RxJS operator that filters out null/undefined observables and then switches to the remaining ones.
173
196
  *
174
197
  * Combines {@link filterMaybe} and `switchMap` to only subscribe to non-nullish observables.
198
+ *
199
+ * @returns operator that filters nullish observables and subscribes to the non-nullish ones
175
200
  */
176
201
  export declare function switchMapFilterMaybe<T = unknown>(): OperatorFunction<Maybe<Observable<Maybe<T>>>, T>;
177
202
  /**
178
203
  * RxJS operator that switches to the emitted observable if defined, or emits `undefined` when the observable is nullish.
204
+ *
205
+ * @returns operator that switches to the emitted observable or emits undefined for null/undefined inputs
179
206
  */
180
207
  export declare function switchMapMaybe<T = unknown>(): OperatorFunction<Maybe<Observable<Maybe<T>>>, Maybe<T>>;
181
208
  /**
@@ -194,20 +221,29 @@ export declare function mapMaybe<A, B>(mapFn: MapFunction<A, Maybe<B>>): Operato
194
221
  */
195
222
  export declare function mapIf<A, B>(mapFn: MapFunction<Maybe<A>, Maybe<B>>, decision: DecisionFunction<Maybe<A>>): OperatorFunction<Maybe<A>, Maybe<B>>;
196
223
  /**
197
- * Combines both combineLatest with map values to an other value.
224
+ * Combines the source observable with another observable via `combineLatest`, then maps the pair to a result.
198
225
  *
199
- * @param combineObs
200
- * @param mapFn
201
- * @returns
226
+ * @param combineObs - the secondary observable to combine with the source
227
+ * @param mapFn - function that maps the source value and combined value to the output
228
+ * @returns operator that combines the source with `combineObs` and maps each pair using `mapFn`
202
229
  */
203
230
  export declare function combineLatestMapFrom<A, B, C>(combineObs: Observable<B>, mapFn: (a: A, b: B) => C): OperatorFunction<A, C>;
204
231
  /**
205
232
  * Creates an observable that emits a starting value, then a second value after a delay.
206
233
  *
207
234
  * If the delay is not provided, or is falsy, then the second value is never emitted.
235
+ *
236
+ * @param startWith - the value to emit immediately
237
+ * @param endWith - the value to emit after the delay
238
+ * @param delayTime - optional delay in milliseconds before emitting the second value
239
+ * @returns an observable that emits `startWith` immediately and `endWith` after the delay (if provided)
208
240
  */
209
- export declare function emitDelayObs<T>(startWith: T, endWith: T, delayTime: Maybe<number>): Observable<T>;
241
+ export declare function emitDelayObs<T>(startWith: T, endWith: T, delayTime: Maybe<Milliseconds>): Observable<T>;
210
242
  /**
211
243
  * Emits a value after a given delay after every new emission.
244
+ *
245
+ * @param value - the value to emit after the delay
246
+ * @param delayTime - duration in milliseconds before emitting the value
247
+ * @returns operator that appends the given value after each source emission with the specified delay
212
248
  */
213
- export declare function emitAfterDelay<T>(value: T, delayTime: number): MonoTypeOperatorFunction<T>;
249
+ export declare function emitAfterDelay<T>(value: T, delayTime: Milliseconds): MonoTypeOperatorFunction<T>;
@@ -26,6 +26,8 @@ export declare class SubscriptionObject<T extends Unsubscribable = Unsubscribabl
26
26
  constructor(sub?: Maybe<T>);
27
27
  /**
28
28
  * Whether a subscription is currently being managed.
29
+ *
30
+ * @returns true if a subscription is currently active
29
31
  */
30
32
  get hasSubscription(): boolean;
31
33
  /**
@@ -77,6 +79,8 @@ export declare class MultiSubscriptionObject<T extends Unsubscribable = Unsubscr
77
79
  constructor(subs?: ArrayOrValue<T>);
78
80
  /**
79
81
  * Whether any subscriptions are currently being managed.
82
+ *
83
+ * @returns true if one or more subscriptions are currently active
80
84
  */
81
85
  get hasSubscription(): boolean;
82
86
  /**
@@ -52,6 +52,8 @@ export interface WorkFactoryConfig<T, O> {
52
52
  * ```
53
53
  *
54
54
  * @param config - work function and delegate configuration
55
+ * @param config.work - the work function to execute for each input value
56
+ * @param config.delegate - delegate that receives lifecycle callbacks (start, success, reject)
55
57
  * @returns a factory function that creates WorkInstance for each input
56
58
  */
57
59
  export declare function workFactory<T, O>({ work, delegate }: WorkFactoryConfig<T, O>): WorkFactory<T, O>;
@@ -61,7 +61,7 @@ export declare class WorkInstance<I = unknown, O = unknown> implements Destroyab
61
61
  *
62
62
  * If the loading state returns an error, the error is forwarded.
63
63
  *
64
- * @param loadingStateObs
64
+ * @param loadingStateObs - observable of the loading state to track as the work result
65
65
  */
66
66
  startWorkingWithLoadingStateObservable(loadingStateObs: Observable<Maybe<LoadingState<O>>>): void;
67
67
  /**
@@ -71,7 +71,8 @@ export declare class WorkInstance<I = unknown, O = unknown> implements Destroyab
71
71
  *
72
72
  * It is used in conjunction with startWorking() and ideal for cases where multiple observables or promises are used.
73
73
  *
74
- * @param loadingStateObs
74
+ * @param loadingStateObs - promise or observable of the loading state to track for errors
75
+ * @returns a promise that resolves with the value from the loading state or rejects on error
75
76
  */
76
77
  performTaskWithLoadingState<T>(loadingStateObs: Promise<LoadingState<T>> | Observable<Maybe<LoadingState<T>>>): Promise<T>;
77
78
  /**
@@ -79,15 +80,19 @@ export declare class WorkInstance<I = unknown, O = unknown> implements Destroyab
79
80
  *
80
81
  * If an error is thrown, the error is forwarded to the reject function.
81
82
  *
82
- * @param fn
83
+ * @param fn - synchronous function that returns the result value or throws an error
83
84
  */
84
85
  performTaskWithReturnValue(fn: () => O): void;
85
86
  /**
86
87
  * Begins working using a promise.
88
+ *
89
+ * @param promise - the promise that represents the asynchronous work
87
90
  */
88
91
  startWorkingWithPromise(promise: Promise<O>): void;
89
92
  /**
90
93
  * Begins working using an observable.
94
+ *
95
+ * @param workObs - the observable that represents the asynchronous work and emits the result
91
96
  */
92
97
  startWorkingWithObservable(workObs: Observable<O>): void;
93
98
  /**
@@ -96,10 +101,14 @@ export declare class WorkInstance<I = unknown, O = unknown> implements Destroyab
96
101
  startWorking(): void;
97
102
  /**
98
103
  * Sets success on the work.
104
+ *
105
+ * @param result - the successful result value to pass to the delegate
99
106
  */
100
107
  success(result?: O): void;
101
108
  /**
102
109
  * Sets rejected on the work.
110
+ *
111
+ * @param error - the error to pass to the delegate as the rejection reason
103
112
  */
104
113
  reject(error?: ErrorInput): void;
105
114
  destroy(): void;