@dereekb/rxjs 13.4.0 → 13.4.2
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 +225 -163
- package/index.esm.js +226 -164
- package/package.json +2 -2
- package/src/lib/filter/filter.map.d.ts +4 -0
- package/src/lib/filter/filter.source.d.ts +9 -3
- package/src/lib/iterator/iteration.accumulator.d.ts +21 -7
- package/src/lib/loading/loading.context.simple.d.ts +2 -0
- package/src/lib/loading/loading.context.state.d.ts +4 -0
- package/src/lib/loading/loading.state.d.ts +6 -0
- package/src/lib/loading/loading.state.rxjs.d.ts +2 -1
- package/src/lib/lock.d.ts +16 -4
- package/src/lib/object.d.ts +1 -1
- package/src/lib/rxjs/boolean.d.ts +6 -0
- package/src/lib/rxjs/expires.d.ts +7 -1
- package/src/lib/rxjs/getter.d.ts +7 -2
- package/src/lib/rxjs/misc.d.ts +1 -1
- package/src/lib/rxjs/model.d.ts +4 -0
- package/src/lib/rxjs/set.d.ts +4 -0
- package/src/lib/rxjs/value.d.ts +40 -4
- package/src/lib/subscription.d.ts +4 -0
- package/src/lib/work/work.factory.d.ts +2 -0
- package/src/lib/work/work.instance.d.ts +12 -3
package/package.json
CHANGED
|
@@ -89,10 +89,14 @@ export declare class FilterMapKeyInstance<F> implements FilterSourceConnector<F>
|
|
|
89
89
|
get key(): FilterMapKey;
|
|
90
90
|
/**
|
|
91
91
|
* Sets the default filter observable for this key.
|
|
92
|
+
*
|
|
93
|
+
* @param filterObs - the observable to use as the default filter for this key
|
|
92
94
|
*/
|
|
93
95
|
initWithFilter(filterObs: Observable<F>): void;
|
|
94
96
|
/**
|
|
95
97
|
* Connects a filter source, adding its filter observable to this key's merged filters.
|
|
98
|
+
*
|
|
99
|
+
* @param filterSource - the filter source whose filter$ will be added to this key's merged stream
|
|
96
100
|
*/
|
|
97
101
|
connectWithSource(filterSource: FilterSource<F>): void;
|
|
98
102
|
}
|
|
@@ -6,11 +6,17 @@ import { type Destroyable, type Maybe } from '@dereekb/util';
|
|
|
6
6
|
* Configuration for initializing a {@link FilterSourceInstance}.
|
|
7
7
|
*/
|
|
8
8
|
export interface FilterSourceInstanceConfig<F> {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Observable used to initialize the filter value, taking priority over the default.
|
|
11
|
+
*/
|
|
10
12
|
readonly initWithFilter?: Maybe<Observable<F>>;
|
|
11
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Default filter value or observable, used as a fallback when no explicit filter is set.
|
|
15
|
+
*/
|
|
12
16
|
readonly defaultFilter?: MaybeObservableOrValue<F>;
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Explicit filter value to set immediately.
|
|
19
|
+
*/
|
|
14
20
|
readonly filter?: Maybe<F>;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
@@ -62,13 +62,21 @@ export interface ItemAccumulatorValuePair<O, I = unknown> extends MapFunctionOut
|
|
|
62
62
|
* and successful states.
|
|
63
63
|
*/
|
|
64
64
|
export interface ItemAccumulatorInstance<O, I = unknown, N extends ItemIteration<I> = ItemIteration<I>> extends ItemAccumulator<O, I, N>, Destroyable {
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Emits `true` once the first load has completed.
|
|
67
|
+
*/
|
|
66
68
|
readonly hasCompletedInitialLoad$: Observable<boolean>;
|
|
67
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* The most recent loading state that completed without an error.
|
|
71
|
+
*/
|
|
68
72
|
readonly latestSuccessfulState$: Observable<LoadingState<I>>;
|
|
69
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* All successful loading states accumulated in order.
|
|
75
|
+
*/
|
|
70
76
|
readonly allSuccessfulStates$: Observable<LoadingState<I>[]>;
|
|
71
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Count of successfully loaded pages so far.
|
|
79
|
+
*/
|
|
72
80
|
readonly successfulLoadCount$: Observable<number>;
|
|
73
81
|
}
|
|
74
82
|
/**
|
|
@@ -92,11 +100,17 @@ export type ItemAccumulatorNextPageUntilResultsCountFunction<O> = MapFunction<O[
|
|
|
92
100
|
* Configuration for {@link itemAccumulatorNextPageUntilResultsCount}.
|
|
93
101
|
*/
|
|
94
102
|
export interface ItemAccumulatorNextPageUntilResultsCountConfig<O> {
|
|
95
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* The accumulator whose iteration will be advanced.
|
|
105
|
+
*/
|
|
96
106
|
readonly accumulator: ItemAccumulator<O, any, PageItemIteration<any>>;
|
|
97
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Target number of results to accumulate before stopping.
|
|
109
|
+
*/
|
|
98
110
|
readonly maxResultsLimit: GetterOrValue<number>;
|
|
99
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Function to count how many meaningful results exist in the accumulated items.
|
|
113
|
+
*/
|
|
100
114
|
readonly countResultsFunction: ItemAccumulatorNextPageUntilResultsCountFunction<O>;
|
|
101
115
|
}
|
|
102
116
|
/**
|
|
@@ -28,6 +28,8 @@ export declare class SimpleLoadingContext implements LoadingContext, Destroyable
|
|
|
28
28
|
destroy(): void;
|
|
29
29
|
/**
|
|
30
30
|
* Whether the current state has a non-null error.
|
|
31
|
+
*
|
|
32
|
+
* @returns true if the current state contains an error
|
|
31
33
|
*/
|
|
32
34
|
hasError(): boolean;
|
|
33
35
|
/**
|
|
@@ -79,6 +79,10 @@ export type LoadingEventForLoadingPairConfigInput = Pick<LoadingStateContextConf
|
|
|
79
79
|
*
|
|
80
80
|
* Determines the `loading` flag based on whether an error is present, whether the value is defined,
|
|
81
81
|
* and the `showLoadingOnUndefinedValue` setting. Loading progress is only included while loading.
|
|
82
|
+
*
|
|
83
|
+
* @param state - the current loading state to convert into a context event
|
|
84
|
+
* @param input - configuration input controlling how the loading flag is derived
|
|
85
|
+
* @returns a loading state context event derived from the given state
|
|
82
86
|
*/
|
|
83
87
|
export declare const DEFAULT_LOADING_EVENT_FOR_LOADING_PAIR_FUNCTION: <T = unknown, S extends LoadingState<T> = LoadingState<T>, E extends LoadingStateContextEvent = LoadingContextEvent & S>(state: S, input: LoadingEventForLoadingPairConfigInput) => LoadingStateContextEvent<T>;
|
|
84
88
|
/**
|
|
@@ -174,6 +174,8 @@ export declare function isLoadingStateFinishedLoading<L extends LoadingState>(st
|
|
|
174
174
|
* // { loading: false }
|
|
175
175
|
* loadingStateType(state); // LoadingStateType.IDLE
|
|
176
176
|
* ```
|
|
177
|
+
*
|
|
178
|
+
* @returns a loading state with `loading: false` and no value or error
|
|
177
179
|
*/
|
|
178
180
|
export declare function idleLoadingState<T>(): LoadingState<T>;
|
|
179
181
|
/**
|
|
@@ -405,6 +407,10 @@ export declare function isPageLoadingStateMetadataEqual(a: Partial<PageLoadingSt
|
|
|
405
407
|
* const merged = mergeLoadingStates(beginLoading(), successResult({ a: 1 }));
|
|
406
408
|
* // { loading: true }
|
|
407
409
|
* ```
|
|
410
|
+
*
|
|
411
|
+
* @param a - the first loading state to merge
|
|
412
|
+
* @param b - the second loading state to merge
|
|
413
|
+
* @returns the combined loading state reflecting the merged values, errors, and loading flags
|
|
408
414
|
*/
|
|
409
415
|
export declare function mergeLoadingStates<A extends object, B extends object>(a: LoadingState<A>, b: LoadingState<B>): LoadingState<A & B>;
|
|
410
416
|
export declare function mergeLoadingStates<A extends object, B extends object, O>(a: LoadingState<A>, b: LoadingState<B>, mergeFn: (a: A, b: B) => O): LoadingState<O>;
|
|
@@ -48,7 +48,8 @@ export declare function loadingStateFromObs<T>(obs: Observable<T>, firstOnly?: b
|
|
|
48
48
|
* // => emits LoadingState<{ sum: number }> with value { sum: 3 }
|
|
49
49
|
* ```
|
|
50
50
|
*
|
|
51
|
-
* @param
|
|
51
|
+
* @param obsA - the first LoadingState observable to combine
|
|
52
|
+
* @param obsB - the second LoadingState observable to combine
|
|
52
53
|
* @returns An observable emitting the merged {@link LoadingState}.
|
|
53
54
|
*/
|
|
54
55
|
export declare function combineLoadingStates<A, B>(obsA: Observable<LoadingState<A>>, obsB: Observable<LoadingState<B>>): Observable<LoadingState<A & B>>;
|
package/src/lib/lock.d.ts
CHANGED
|
@@ -19,13 +19,21 @@ export type RemoveLockFunction = () => void;
|
|
|
19
19
|
* Configuration for {@link onLockSetNextUnlock} that specifies how to wait for a {@link LockSet} to unlock.
|
|
20
20
|
*/
|
|
21
21
|
export interface OnLockSetUnlockedConfig {
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The lock set to monitor for the next unlock event.
|
|
24
|
+
*/
|
|
23
25
|
readonly lockSet: LockSet;
|
|
24
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Optional callback to invoke when the lock set unlocks or the timeout is reached.
|
|
28
|
+
*/
|
|
25
29
|
readonly fn?: Maybe<OnLockSetUnlockedFunction>;
|
|
26
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Maximum time in milliseconds to wait for unlock before timing out. Defaults to 50 seconds.
|
|
32
|
+
*/
|
|
27
33
|
readonly timeout?: Maybe<Milliseconds>;
|
|
28
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Optional delay in milliseconds after the unlock is detected before invoking the callback.
|
|
36
|
+
*/
|
|
29
37
|
readonly delayTime?: Maybe<Milliseconds>;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
@@ -57,6 +65,10 @@ export declare const DEFAULT_LOCK_SET_TIME_LOCK_KEY = "timelock";
|
|
|
57
65
|
* Useful for deferring an action until all locks are released, with a safety timeout to avoid waiting indefinitely.
|
|
58
66
|
*
|
|
59
67
|
* @param config - configuration specifying the lock set, callback, timeout, and optional delay
|
|
68
|
+
* @param config.lockSet - the lock set to monitor for the next unlock event
|
|
69
|
+
* @param config.fn - optional callback to invoke when the lock set unlocks or the timeout is reached
|
|
70
|
+
* @param config.timeout - maximum time in milliseconds to wait before timing out
|
|
71
|
+
* @param config.delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
60
72
|
* @returns subscription that can be unsubscribed to cancel the wait
|
|
61
73
|
*
|
|
62
74
|
* @example
|
package/src/lib/object.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function distinctUntilObjectValuesChanged<T>(): MonoTypeOperatorF
|
|
|
22
22
|
* Accepts either a static reference value or an observable of reference values. When given an observable,
|
|
23
23
|
* each emission is compared against the latest reference value. Uses {@link areEqualPOJOValues} for comparison.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param inputFilter - static reference value or observable of reference values to compare against
|
|
26
26
|
* @returns operator that only passes through values that differ from the reference
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
@@ -9,13 +9,19 @@ import { type OperatorFunction, type MonoTypeOperatorFunction } from 'rxjs';
|
|
|
9
9
|
export declare function pipeIf<A>(usePipe: boolean, pipe: OperatorFunction<A, A>): OperatorFunction<A, A>;
|
|
10
10
|
/**
|
|
11
11
|
* RxJS operator that negates each emitted boolean value.
|
|
12
|
+
*
|
|
13
|
+
* @returns operator that maps each boolean emission to its negated value
|
|
12
14
|
*/
|
|
13
15
|
export declare function isNot(): MonoTypeOperatorFunction<boolean>;
|
|
14
16
|
/**
|
|
15
17
|
* RxJS operator that only emits when a boolean stream transitions from `true` to `false`.
|
|
18
|
+
*
|
|
19
|
+
* @returns operator that filters to only true-to-false transition emissions
|
|
16
20
|
*/
|
|
17
21
|
export declare function onTrueToFalse(): MonoTypeOperatorFunction<boolean>;
|
|
18
22
|
/**
|
|
19
23
|
* RxJS operator that only emits when a boolean stream transitions from `false` to `true`.
|
|
24
|
+
*
|
|
25
|
+
* @returns operator that filters to only false-to-true transition emissions
|
|
20
26
|
*/
|
|
21
27
|
export declare function onFalseToTrue(): MonoTypeOperatorFunction<boolean>;
|
|
@@ -5,23 +5,27 @@ import { type MonoTypeOperatorFunction, type Observable, type OperatorFunction }
|
|
|
5
5
|
* time relative to the current moment.
|
|
6
6
|
*
|
|
7
7
|
* @param expiresIn - duration in milliseconds until expiration
|
|
8
|
-
* @returns an
|
|
8
|
+
* @returns an `OperatorFunction` that maps each emission to an {@link Expires} object
|
|
9
9
|
*/
|
|
10
10
|
export declare function toExpiration<T>(expiresIn: number): OperatorFunction<T, Expires>;
|
|
11
11
|
/**
|
|
12
12
|
* RxJS operator that filters out emissions whose {@link Expires} value has already expired.
|
|
13
|
+
*
|
|
14
|
+
* @returns operator that only passes through non-expired emissions
|
|
13
15
|
*/
|
|
14
16
|
export declare function skipExpired<T extends Expires>(): MonoTypeOperatorFunction<T>;
|
|
15
17
|
/**
|
|
16
18
|
* RxJS operator that skips emissions until the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
17
19
|
*
|
|
18
20
|
* @param expiresIn - duration in milliseconds
|
|
21
|
+
* @returns operator that skips emissions until the time window has elapsed
|
|
19
22
|
*/
|
|
20
23
|
export declare function skipUntilExpiration(expiresIn?: number): MonoTypeOperatorFunction<DateOrUnixDateTimeMillisecondsNumber>;
|
|
21
24
|
/**
|
|
22
25
|
* RxJS operator that skips emissions after the elapsed time since the emitted date/timestamp has exceeded `expiresIn`.
|
|
23
26
|
*
|
|
24
27
|
* @param expiresIn - duration in milliseconds
|
|
28
|
+
* @returns operator that passes through emissions only within the time window
|
|
25
29
|
*/
|
|
26
30
|
export declare function skipAfterExpiration(expiresIn?: number): MonoTypeOperatorFunction<DateOrUnixDateTimeMillisecondsNumber>;
|
|
27
31
|
/**
|
|
@@ -29,6 +33,7 @@ export declare function skipAfterExpiration(expiresIn?: number): MonoTypeOperato
|
|
|
29
33
|
*
|
|
30
34
|
* @param watch - observable whose emissions reset the time window
|
|
31
35
|
* @param takeFor - duration in milliseconds of each time window
|
|
36
|
+
* @returns operator that limits source emissions to the active time window after each watch emission
|
|
32
37
|
*/
|
|
33
38
|
export declare function skipUntilTimeElapsedAfterLastEmission<T>(watch: Observable<unknown>, takeFor: Milliseconds): MonoTypeOperatorFunction<T>;
|
|
34
39
|
/**
|
|
@@ -37,5 +42,6 @@ export declare function skipUntilTimeElapsedAfterLastEmission<T>(watch: Observab
|
|
|
37
42
|
*
|
|
38
43
|
* @param watch - observable whose emissions reset the skip window
|
|
39
44
|
* @param skipFor - duration in milliseconds to skip after each watch emission
|
|
45
|
+
* @returns an operator that delays passing values through until time has elapsed since the last watch emission
|
|
40
46
|
*/
|
|
41
47
|
export declare function takeAfterTimeElapsedSinceLastEmission<T>(watch: Observable<unknown>, skipFor: Milliseconds): MonoTypeOperatorFunction<T>;
|
package/src/lib/rxjs/getter.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type ObservableOrValue<T> = T | Observable<T>;
|
|
|
7
7
|
export type MaybeObservableOrValue<T> = Maybe<ObservableOrValue<Maybe<T>>>;
|
|
8
8
|
/**
|
|
9
9
|
* Wraps a value as an observable using `of()`, or returns it directly if it is already an observable.
|
|
10
|
+
*
|
|
11
|
+
* @param valueOrObs - the value or observable to wrap
|
|
12
|
+
* @returns an observable that emits the given value, or the original observable if already one
|
|
10
13
|
*/
|
|
11
14
|
export declare function asObservable<T>(valueOrObs: ObservableOrValue<T>): Observable<T>;
|
|
12
15
|
export declare function asObservable<T>(valueOrObs: Maybe<ObservableOrValue<T>>): Observable<Maybe<T>>;
|
|
@@ -51,14 +54,16 @@ export declare function valueFromObservableOrValueGetter<T>(): OperatorFunction<
|
|
|
51
54
|
/**
|
|
52
55
|
* RxJS operator that flattens an emitted Maybe<{@link ObservableOrValueGetter}> into its resolved value,
|
|
53
56
|
* emitting `undefined` when the input is nullish.
|
|
57
|
+
*
|
|
58
|
+
* @returns an operator that unwraps Maybe<ObservableOrValueGetter> emissions, emitting undefined for nullish inputs
|
|
54
59
|
*/
|
|
55
60
|
export declare function maybeValueFromObservableOrValueGetter<T>(): OperatorFunction<MaybeObservableOrValueGetter<T>, Maybe<T>>;
|
|
56
61
|
/**
|
|
57
62
|
* Subscribes to an {@link ObservableOrValue} and calls the observer/next function with each emitted value.
|
|
58
63
|
*
|
|
59
64
|
* @param input - the observable or value to subscribe to
|
|
60
|
-
* @param
|
|
61
|
-
* @returns the subscription
|
|
65
|
+
* @param next - callback function or partial observer to handle each emitted value
|
|
66
|
+
* @returns the resulting subscription
|
|
62
67
|
*/
|
|
63
68
|
export declare function useAsObservable<T>(input: ObservableOrValue<T>, next: (value: T) => void): Subscription;
|
|
64
69
|
export declare function useAsObservable<T>(input: ObservableOrValue<T>, observer: Partial<Observer<T>>): Subscription;
|
package/src/lib/rxjs/misc.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { type MonoTypeOperatorFunction, type SchedulerLike } from 'rxjs';
|
|
|
13
13
|
* // logs "Value: <emitted value>" for each emission
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param message - static label or function returning log arguments
|
|
17
17
|
* @param consoleLogFn - which console method to use (defaults to 'log')
|
|
18
18
|
* @returns a tap operator that logs emissions
|
|
19
19
|
*/
|
package/src/lib/rxjs/model.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type ModelKeyRef, type UniqueModel } from '@dereekb/util';
|
|
2
2
|
/**
|
|
3
3
|
* `distinctUntilChanged` variant that only emits when the model's `id` property changes.
|
|
4
|
+
*
|
|
5
|
+
* @returns operator that suppresses consecutive emissions with the same model `id`
|
|
4
6
|
*/
|
|
5
7
|
export declare function distinctUntilModelIdChange<T extends UniqueModel>(): import("rxjs").MonoTypeOperatorFunction<T>;
|
|
6
8
|
/**
|
|
7
9
|
* `distinctUntilChanged` variant that only emits when the model's `key` property changes.
|
|
10
|
+
*
|
|
11
|
+
* @returns operator that suppresses consecutive emissions with the same model `key`
|
|
8
12
|
*/
|
|
9
13
|
export declare function distinctUntilModelKeyChange<T extends ModelKeyRef>(): import("rxjs").MonoTypeOperatorFunction<T>;
|
package/src/lib/rxjs/set.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare function setContainsAnyValueFrom<T>(valuesObs: Observable<Maybe<I
|
|
|
23
23
|
export declare function setContainsNoValueFrom<T>(valuesObs: Observable<Maybe<Iterable<T>>>): OperatorFunction<Set<T>, boolean>;
|
|
24
24
|
/**
|
|
25
25
|
* `distinctUntilChanged` variant for iterables that only emits when the contained values change.
|
|
26
|
+
*
|
|
27
|
+
* @returns operator that suppresses consecutive iterable emissions with the same set of values
|
|
26
28
|
*/
|
|
27
29
|
export declare function distinctUntilHasDifferentValues<I extends Iterable<K>, K extends PrimativeKey>(): MonoTypeOperatorFunction<I>;
|
|
28
30
|
/**
|
|
@@ -30,6 +32,7 @@ export declare function distinctUntilHasDifferentValues<I extends Iterable<K>, K
|
|
|
30
32
|
* when the set of extracted values changes.
|
|
31
33
|
*
|
|
32
34
|
* @param readValues - function to extract the iterable of values to compare
|
|
35
|
+
* @returns operator that suppresses consecutive emissions whose extracted iterable values are the same
|
|
33
36
|
*/
|
|
34
37
|
export declare function distinctUntilItemsHaveDifferentValues<I, V extends Iterable<PrimativeKey>>(readValues: ReadValueFunction<I, V>): MonoTypeOperatorFunction<I>;
|
|
35
38
|
export declare function distinctUntilItemsHaveDifferentValues<I, V extends Iterable<PrimativeKey>>(readValues: ReadValueFunction<I, V>): MonoTypeOperatorFunction<Maybe<I>>;
|
|
@@ -39,6 +42,7 @@ export declare function distinctUntilItemsHaveDifferentValues<I, V extends Itera
|
|
|
39
42
|
*
|
|
40
43
|
* @param readValues - function to extract the value to compare
|
|
41
44
|
* @param isEqualComparator - custom equality function for the extracted values
|
|
45
|
+
* @returns operator that suppresses consecutive emissions whose extracted values are considered equal
|
|
42
46
|
*/
|
|
43
47
|
export declare function distinctUntilItemsValueChanges<I, V>(readValues: ReadValueFunction<I, V>, isEqualComparator: EqualityComparatorFunction<V>): MonoTypeOperatorFunction<I>;
|
|
44
48
|
export declare function distinctUntilItemsValueChanges<I, V>(readValues: ReadValueFunction<I, V>, isEqualComparator: EqualityComparatorFunction<V>): MonoTypeOperatorFunction<Maybe<I>>;
|
package/src/lib/rxjs/value.d.ts
CHANGED
|
@@ -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
|
/**
|
|
@@ -140,11 +153,17 @@ export interface SwitchMapObjectConfig<T> {
|
|
|
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
|
|
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
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
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;
|