@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.
- package/index.cjs.js +240 -184
- package/index.esm.js +241 -185
- 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 +11 -5
- package/src/lib/loading/loading.state.rxjs.d.ts +6 -5
- package/src/lib/lock.d.ts +25 -13
- 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/rxjs.async.d.ts +5 -5
- package/src/lib/rxjs/set.d.ts +4 -0
- package/src/lib/rxjs/value.d.ts +44 -8
- 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>;
|
|
@@ -443,8 +449,8 @@ export declare function mergeLoadingStateWithValue<S extends LoadingState>(state
|
|
|
443
449
|
export declare function mergeLoadingStateWithError<S extends LoadingState = LoadingState>(state: S, error?: ReadableDataError): S;
|
|
444
450
|
export type MapMultipleLoadingStateValuesFn<T, X> = (input: X[]) => T;
|
|
445
451
|
export interface MapMultipleLoadingStateResultsConfiguration<T, X, L extends LoadingState<X>[], R extends LoadingState<T>> {
|
|
446
|
-
mapValues?: MapMultipleLoadingStateValuesFn<T, X>;
|
|
447
|
-
mapState?: (input: L) => R;
|
|
452
|
+
readonly mapValues?: MapMultipleLoadingStateValuesFn<T, X>;
|
|
453
|
+
readonly mapState?: (input: L) => R;
|
|
448
454
|
}
|
|
449
455
|
/**
|
|
450
456
|
* Maps multiple {@link LoadingState} results into a single state using a value mapping or state mapping function.
|
|
@@ -461,9 +467,9 @@ export declare function mapMultipleLoadingStateResults<T, X, L extends LoadingSt
|
|
|
461
467
|
export type MapLoadingStateFn<A, B, L extends LoadingState<A> = LoadingState<A>, O extends LoadingState<B> = LoadingState<B>> = (input: L, value?: B) => O;
|
|
462
468
|
export type MapLoadingStateValuesFn<A, B, L extends LoadingState<A> = LoadingState<A>> = (input: A, state: L) => B;
|
|
463
469
|
export interface MapLoadingStateResultsConfiguration<A, B, L extends LoadingState<A> = LoadingState<A>, O extends LoadingState<B> = LoadingState<B>> {
|
|
464
|
-
alwaysMapValue?: boolean;
|
|
465
|
-
mapValue?: MapLoadingStateValuesFn<A, B, L>;
|
|
466
|
-
mapState?: MapLoadingStateFn<A, B, L, O>;
|
|
470
|
+
readonly alwaysMapValue?: boolean;
|
|
471
|
+
readonly mapValue?: MapLoadingStateValuesFn<A, B, L>;
|
|
472
|
+
readonly mapState?: MapLoadingStateFn<A, B, L, O>;
|
|
467
473
|
}
|
|
468
474
|
/**
|
|
469
475
|
* Maps the value of a single {@link LoadingState} to a new type using the provided configuration.
|
|
@@ -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>>;
|
|
@@ -350,19 +351,19 @@ export interface DistinctLoadingStateConfig<L extends LoadingState> {
|
|
|
350
351
|
*
|
|
351
352
|
* By default this uses a DecisionFunction that returns true on undefined and false on null.
|
|
352
353
|
*/
|
|
353
|
-
passRetainedValue?: (value: Maybe<LoadingStateValue<L>>, previousValue: Maybe<LoadingStateValue<L>>, state: L, previousState: Maybe<L>) => boolean;
|
|
354
|
+
readonly passRetainedValue?: (value: Maybe<LoadingStateValue<L>>, previousValue: Maybe<LoadingStateValue<L>>, state: L, previousState: Maybe<L>) => boolean;
|
|
354
355
|
/**
|
|
355
356
|
* Whether or not to compare the
|
|
356
357
|
*/
|
|
357
|
-
compareOnUndefinedValue?: boolean;
|
|
358
|
+
readonly compareOnUndefinedValue?: boolean;
|
|
358
359
|
/**
|
|
359
360
|
* Used for comparing the values of the LoadingState.
|
|
360
361
|
*/
|
|
361
|
-
valueComparator: EqualityComparatorFunction<Maybe<LoadingStateValue<L>>>;
|
|
362
|
+
readonly valueComparator: EqualityComparatorFunction<Maybe<LoadingStateValue<L>>>;
|
|
362
363
|
/**
|
|
363
364
|
* Used for comparing the metadata values of the LoadingState. By default uses isPageLoadingStateMetadataEqual.
|
|
364
365
|
*/
|
|
365
|
-
metadataComparator?: EqualityComparatorFunction<Maybe<Partial<L>>>;
|
|
366
|
+
readonly metadataComparator?: EqualityComparatorFunction<Maybe<Partial<L>>>;
|
|
366
367
|
}
|
|
367
368
|
/**
|
|
368
369
|
* A special `distinctUntilChanged`-like operator for {@link LoadingState} and {@link PageLoadingState}.
|
package/src/lib/lock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ObservableOrValue } from './rxjs/getter';
|
|
2
2
|
import { type Subscription, type Observable } from 'rxjs';
|
|
3
|
-
import { type Destroyable, type Maybe } from '@dereekb/util';
|
|
3
|
+
import { type Destroyable, type Maybe, type Milliseconds, type Seconds } from '@dereekb/util';
|
|
4
4
|
/**
|
|
5
5
|
* Key used to identify a specific lock within a {@link LockSet}.
|
|
6
6
|
*/
|
|
@@ -19,14 +19,22 @@ 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
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly
|
|
30
|
+
/**
|
|
31
|
+
* Maximum time in milliseconds to wait for unlock before timing out. Defaults to 50 seconds.
|
|
32
|
+
*/
|
|
33
|
+
readonly timeout?: Maybe<Milliseconds>;
|
|
34
|
+
/**
|
|
35
|
+
* Optional delay in milliseconds after the unlock is detected before invoking the callback.
|
|
36
|
+
*/
|
|
37
|
+
readonly delayTime?: Maybe<Milliseconds>;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* Configuration for {@link LockSet.destroyOnNextUnlock}, excluding the lock set reference.
|
|
@@ -45,7 +53,7 @@ export interface SetLockedConfig {
|
|
|
45
53
|
*
|
|
46
54
|
* Only relevant for locking.
|
|
47
55
|
*/
|
|
48
|
-
readonly duration?:
|
|
56
|
+
readonly duration?: Milliseconds;
|
|
49
57
|
}
|
|
50
58
|
/**
|
|
51
59
|
* Default lock key used by {@link LockSet.lockForTime} when no custom key is provided.
|
|
@@ -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
|
|
@@ -132,20 +144,20 @@ export declare class LockSet implements Destroyable {
|
|
|
132
144
|
* @param duration - optional auto-unlock duration in milliseconds (only used with boolean config)
|
|
133
145
|
*/
|
|
134
146
|
setLocked(key: LockKey, config: SetLockedConfig): void;
|
|
135
|
-
setLocked(key: LockKey, config: boolean, duration?:
|
|
147
|
+
setLocked(key: LockKey, config: boolean, duration?: Milliseconds): void;
|
|
136
148
|
/**
|
|
137
149
|
* Locks for a specified number of seconds using the default time lock key.
|
|
138
150
|
*
|
|
139
151
|
* @param seconds - duration in seconds
|
|
140
152
|
*/
|
|
141
|
-
lockForSeconds(seconds:
|
|
153
|
+
lockForSeconds(seconds: Seconds): void;
|
|
142
154
|
/**
|
|
143
155
|
* Locks for a specified duration in milliseconds, automatically unlocking when the time elapses.
|
|
144
156
|
*
|
|
145
157
|
* @param milliseconds - lock duration
|
|
146
158
|
* @param key - optional lock key, defaults to {@link DEFAULT_LOCK_SET_TIME_LOCK_KEY}
|
|
147
159
|
*/
|
|
148
|
-
lockForTime(milliseconds:
|
|
160
|
+
lockForTime(milliseconds: Milliseconds, key?: LockKey): void;
|
|
149
161
|
/**
|
|
150
162
|
* Registers a lock observable under the given key. The lock is considered active when
|
|
151
163
|
* the observable emits `true`. Empty observables are treated as unlocked.
|
|
@@ -178,7 +190,7 @@ export declare class LockSet implements Destroyable {
|
|
|
178
190
|
* @param delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
179
191
|
* @returns subscription that can be unsubscribed to cancel the wait
|
|
180
192
|
*/
|
|
181
|
-
onNextUnlock(config: OnLockSetUnlockedFunction | Omit<OnLockSetUnlockedConfig, 'lockSet'>, delayTime?:
|
|
193
|
+
onNextUnlock(config: OnLockSetUnlockedFunction | Omit<OnLockSetUnlockedConfig, 'lockSet'>, delayTime?: Milliseconds): Subscription;
|
|
182
194
|
/**
|
|
183
195
|
* Establishes a parent-child relationship where this lock set's locked state is propagated
|
|
184
196
|
* to the parent. When this lock set is locked, the parent will also reflect a locked state.
|
|
@@ -204,7 +216,7 @@ export declare class LockSet implements Destroyable {
|
|
|
204
216
|
* @param config - optional callback or configuration for the unlock wait
|
|
205
217
|
* @param delayTime - optional delay in milliseconds after unlock before invoking the callback
|
|
206
218
|
*/
|
|
207
|
-
destroyOnNextUnlock(config?: Maybe<DestroyOnNextUnlockConfig['fn'] | DestroyOnNextUnlockConfig>, delayTime?:
|
|
219
|
+
destroyOnNextUnlock(config?: Maybe<DestroyOnNextUnlockConfig['fn'] | DestroyOnNextUnlockConfig>, delayTime?: Milliseconds): void;
|
|
208
220
|
/**
|
|
209
221
|
* Completes all internal subjects, unsubscribes from the parent lock set, and marks this lock set as destroyed.
|
|
210
222
|
*/
|
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>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CachedFactoryWithInput, type Destroyable } from '@dereekb/util';
|
|
1
|
+
import { type CachedFactoryWithInput, type Destroyable, type Milliseconds } from '@dereekb/util';
|
|
2
2
|
import { type Observable, type Subject } from 'rxjs';
|
|
3
3
|
/**
|
|
4
4
|
* Default amount of throttle in milliseconds used by AsyncPusher.
|
|
@@ -25,19 +25,19 @@ export interface AsyncPusherConfig<T> {
|
|
|
25
25
|
/**
|
|
26
26
|
* Time to throttle each emission.
|
|
27
27
|
*/
|
|
28
|
-
throttle?:
|
|
28
|
+
readonly throttle?: Milliseconds;
|
|
29
29
|
/**
|
|
30
30
|
* Whether or not to filter on distinct values.
|
|
31
31
|
*/
|
|
32
|
-
distinct?: boolean;
|
|
32
|
+
readonly distinct?: boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Configuration function to build onto the internal observable.
|
|
35
35
|
*/
|
|
36
|
-
pipe?: (obs: Observable<T>) => Observable<T>;
|
|
36
|
+
readonly pipe?: (obs: Observable<T>) => Observable<T>;
|
|
37
37
|
/**
|
|
38
38
|
* (Optional) Observable to watch for cleaunup.
|
|
39
39
|
*/
|
|
40
|
-
cleanupObs?: Observable<unknown>;
|
|
40
|
+
readonly cleanupObs?: Observable<unknown>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Creates an {@link AsyncPusher} — a callable function backed by a throttled {@link BehaviorSubject}.
|
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>>;
|