@dereekb/rxjs 13.0.7 → 13.2.0
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 +1284 -336
- package/index.cjs.js.map +1 -1
- package/index.esm.js +1284 -336
- package/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/filter/filter.d.ts +28 -13
- package/src/lib/filter/filter.map.d.ts +69 -2
- package/src/lib/filter/filter.preset.d.ts +35 -0
- package/src/lib/filter/filter.source.d.ts +61 -2
- package/src/lib/iterator/iteration.accumulator.d.ts +39 -13
- package/src/lib/iterator/iteration.accumulator.rxjs.d.ts +25 -8
- package/src/lib/iterator/iteration.d.ts +16 -5
- package/src/lib/iterator/iteration.mapped.d.ts +19 -6
- package/src/lib/iterator/iteration.mapped.page.d.ts +9 -6
- package/src/lib/iterator/iteration.next.d.ts +17 -14
- package/src/lib/iterator/iterator.page.d.ts +54 -16
- package/src/lib/loading/loading.context.rxjs.d.ts +17 -1
- package/src/lib/loading/loading.context.simple.d.ts +38 -1
- package/src/lib/loading/loading.context.state.d.ts +32 -4
- package/src/lib/loading/loading.context.state.list.d.ts +25 -3
- package/src/lib/loading/loading.context.value.d.ts +43 -3
- package/src/lib/loading/loading.state.d.ts +272 -41
- package/src/lib/loading/loading.state.list.d.ts +50 -9
- package/src/lib/lock.d.ts +149 -6
- package/src/lib/object.d.ts +28 -4
- package/src/lib/rxjs/array.d.ts +39 -13
- package/src/lib/rxjs/boolean.d.ts +8 -4
- package/src/lib/rxjs/decision.d.ts +13 -7
- package/src/lib/rxjs/delta.d.ts +14 -2
- package/src/lib/rxjs/expires.d.ts +20 -8
- package/src/lib/rxjs/factory.d.ts +16 -3
- package/src/lib/rxjs/getter.d.ts +24 -10
- package/src/lib/rxjs/key.d.ts +7 -5
- package/src/lib/rxjs/lifecycle.d.ts +10 -7
- package/src/lib/rxjs/loading.d.ts +10 -2
- package/src/lib/rxjs/map.d.ts +6 -5
- package/src/lib/rxjs/misc.d.ts +26 -6
- package/src/lib/rxjs/model.d.ts +2 -2
- package/src/lib/rxjs/number.d.ts +8 -4
- package/src/lib/rxjs/rxjs.async.d.ts +20 -7
- package/src/lib/rxjs/rxjs.d.ts +26 -18
- package/src/lib/rxjs/rxjs.error.d.ts +17 -0
- package/src/lib/rxjs/rxjs.map.d.ts +37 -9
- package/src/lib/rxjs/rxjs.unique.d.ts +6 -3
- package/src/lib/rxjs/set.d.ts +34 -0
- package/src/lib/rxjs/string.d.ts +18 -1
- package/src/lib/rxjs/timeout.d.ts +21 -1
- package/src/lib/rxjs/use.d.ts +4 -2
- package/src/lib/rxjs/value.d.ts +73 -39
- package/src/lib/subscription.d.ts +80 -3
- package/src/lib/work/work.factory.d.ts +42 -9
- package/src/lib/work/work.instance.d.ts +26 -2
package/src/lib/rxjs/map.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ import { type OperatorFunction, type MonoTypeOperatorFunction } from 'rxjs';
|
|
|
2
2
|
import { type MapKeysIntersectionObject } from '@dereekb/util';
|
|
3
3
|
import { type ObservableOrValue } from './getter';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* RxJS operator that extracts values from a keyed object using a keys observable,
|
|
6
|
+
* returning only the values whose keys are present in both.
|
|
6
7
|
*
|
|
7
|
-
* @param keysObs
|
|
8
|
-
* @returns
|
|
8
|
+
* @param keysObs - observable (or static value) of keys to intersect with
|
|
9
|
+
* @returns an operator that maps a keyed object to an array of matching values
|
|
9
10
|
*/
|
|
10
11
|
export declare function mapKeysIntersectionToArray<T>(keysObs: ObservableOrValue<Iterable<string>>): OperatorFunction<MapKeysIntersectionObject<T>, T[]>;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* `distinctUntilChanged` variant for `Map` instances that only emits when the set of map keys changes.
|
|
13
14
|
*
|
|
14
|
-
* @returns
|
|
15
|
+
* @returns an operator that filters out Maps with unchanged key sets
|
|
15
16
|
*/
|
|
16
17
|
export declare function distinctUntilMapHasDifferentKeys<I extends Map<K, V>, K, V>(): MonoTypeOperatorFunction<I>;
|
package/src/lib/rxjs/misc.d.ts
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
import { type RandomNumberFactoryConfig, type RandomNumberFactory } from '@dereekb/util';
|
|
2
2
|
import { type MonoTypeOperatorFunction, type SchedulerLike } from 'rxjs';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* RxJS operator that logs each emission to the console as a side-effect.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Accepts either a static label or a function that produces log arguments from the emitted value.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* source$.pipe(
|
|
11
|
+
* tapLog('Value:')
|
|
12
|
+
* ).subscribe();
|
|
13
|
+
* // logs "Value: <emitted value>" for each emission
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param messageOrFunction - static label or function returning log arguments
|
|
17
|
+
* @param consoleLogFn - which console method to use (defaults to 'log')
|
|
18
|
+
* @returns a tap operator that logs emissions
|
|
8
19
|
*/
|
|
9
20
|
export declare function tapLog<T = unknown>(message: string | number, consoleLogFn?: 'log' | 'warn' | 'error'): MonoTypeOperatorFunction<T>;
|
|
10
21
|
export declare function tapLog<T = unknown>(messageFunction: (value: T) => unknown[], consoleLogFn?: 'log' | 'warn' | 'error'): MonoTypeOperatorFunction<T>;
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* RxJS operator that adds a random delay before each emission.
|
|
24
|
+
*
|
|
25
|
+
* Useful for simulating network latency or staggering requests.
|
|
13
26
|
*
|
|
14
|
-
* @param maxOrArgs
|
|
15
|
-
* @returns
|
|
27
|
+
* @param maxOrArgs - maximum delay in ms, or a full random number config
|
|
28
|
+
* @returns an operator that delays each emission by a random amount
|
|
16
29
|
*/
|
|
17
30
|
export declare function randomDelay<T = unknown>(maxOrArgs: number | RandomNumberFactoryConfig): MonoTypeOperatorFunction<T>;
|
|
31
|
+
/**
|
|
32
|
+
* RxJS operator that adds a random delay using a custom random number generator.
|
|
33
|
+
*
|
|
34
|
+
* @param makeRandomDelay - factory that produces random delay values
|
|
35
|
+
* @param scheduler - the scheduler to use for the delay (defaults to asyncScheduler)
|
|
36
|
+
* @returns an operator that delays each emission
|
|
37
|
+
*/
|
|
18
38
|
export declare function randomDelayWithRandomFunction<T = unknown>(makeRandomDelay: RandomNumberFactory, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
|
package/src/lib/rxjs/model.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ModelKeyRef, type UniqueModel } from '@dereekb/util';
|
|
2
2
|
/**
|
|
3
|
-
* distinctUntilChanged
|
|
3
|
+
* `distinctUntilChanged` variant that only emits when the model's `id` property changes.
|
|
4
4
|
*/
|
|
5
5
|
export declare function distinctUntilModelIdChange<T extends UniqueModel>(): import("rxjs").MonoTypeOperatorFunction<T>;
|
|
6
6
|
/**
|
|
7
|
-
* distinctUntilChanged
|
|
7
|
+
* `distinctUntilChanged` variant that only emits when the model's `key` property changes.
|
|
8
8
|
*/
|
|
9
9
|
export declare function distinctUntilModelKeyChange<T extends ModelKeyRef>(): import("rxjs").MonoTypeOperatorFunction<T>;
|
package/src/lib/rxjs/number.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { type IncrementingNumberFactoryConfig } from '@dereekb/util';
|
|
|
2
2
|
import { type Observable, type OperatorFunction } from 'rxjs';
|
|
3
3
|
import { type FactoryTimerConfig } from './factory';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* RxJS operator that counts emissions as they occur using `scan`, emitting the running count
|
|
6
|
+
* after each emission (unlike `count()` which only emits on completion).
|
|
7
|
+
*
|
|
8
|
+
* @param startAt - initial count value (defaults to 0)
|
|
9
|
+
* @returns an operator that emits the running emission count
|
|
6
10
|
*/
|
|
7
11
|
export declare function scanCount(startAt?: number): OperatorFunction<unknown, number>;
|
|
8
12
|
/**
|
|
@@ -11,9 +15,9 @@ export declare function scanCount(startAt?: number): OperatorFunction<unknown, n
|
|
|
11
15
|
export interface IncrementingTimerConfig extends Omit<FactoryTimerConfig<number>, 'factory'>, IncrementingNumberFactoryConfig {
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
|
-
* Creates a factoryTimer
|
|
18
|
+
* Creates a {@link factoryTimer} that emits incrementing numbers on an interval.
|
|
15
19
|
*
|
|
16
|
-
* @param config
|
|
17
|
-
* @returns
|
|
20
|
+
* @param config - timer and incrementing number configuration
|
|
21
|
+
* @returns an observable of incrementing numbers
|
|
18
22
|
*/
|
|
19
23
|
export declare function incrementingNumberTimer(config?: IncrementingTimerConfig): Observable<number>;
|
|
@@ -40,10 +40,23 @@ export interface AsyncPusherConfig<T> {
|
|
|
40
40
|
cleanupObs?: Observable<unknown>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Creates an AsyncPusher.
|
|
43
|
+
* Creates an {@link AsyncPusher} — a callable function backed by a throttled {@link BehaviorSubject}.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* Each call pushes a value onto the internal subject and returns the shared, throttled observable.
|
|
46
|
+
* Useful for debouncing repeated calls while sharing a single observable output.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const pusher = asyncPusher<string>({ throttle: 100 });
|
|
51
|
+
* const result$ = pusher('hello');
|
|
52
|
+
* // subsequent calls within 100ms are throttled
|
|
53
|
+
* pusher('world');
|
|
54
|
+
* // clean up
|
|
55
|
+
* pusher.destroy();
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param config - optional throttle, distinct, and pipe settings
|
|
59
|
+
* @returns an async pusher function
|
|
47
60
|
*/
|
|
48
61
|
export declare function asyncPusher<T>(config?: AsyncPusherConfig<T>): AsyncPusher<T>;
|
|
49
62
|
/**
|
|
@@ -51,11 +64,11 @@ export declare function asyncPusher<T>(config?: AsyncPusherConfig<T>): AsyncPush
|
|
|
51
64
|
*/
|
|
52
65
|
export type AsyncPusherCache<T> = CachedFactoryWithInput<AsyncPusher<T>, Observable<unknown>>;
|
|
53
66
|
/**
|
|
54
|
-
* Creates a
|
|
67
|
+
* Creates a cached factory that lazily creates and returns an {@link AsyncPusher}.
|
|
55
68
|
*
|
|
56
|
-
* The
|
|
69
|
+
* The factory optionally accepts a cleanup observable — when it completes, the pusher is destroyed.
|
|
57
70
|
*
|
|
58
|
-
* @param config
|
|
59
|
-
* @returns
|
|
71
|
+
* @param config - optional config passed to the underlying async pusher
|
|
72
|
+
* @returns a cached factory that produces an async pusher
|
|
60
73
|
*/
|
|
61
74
|
export declare function asyncPusherCache<T>(config?: AsyncPusherConfig<T>): AsyncPusherCache<T>;
|
package/src/lib/rxjs/rxjs.d.ts
CHANGED
|
@@ -1,38 +1,46 @@
|
|
|
1
1
|
import { type Getter, type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type Observable, type MonoTypeOperatorFunction } from 'rxjs';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Combines `startWith` and {@link tapFirst} to initialize an observable pipe with a side-effect on the first emission.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
6
|
+
* Emits the `initial` value first, then taps on the first emitted value to run the provided callback.
|
|
7
|
+
*
|
|
8
|
+
* @param tap - side-effect function called with the first value
|
|
9
|
+
* @param initial - optional starting value emitted before the source
|
|
10
|
+
* @param skipFirst - if true, skips tapping the initial value
|
|
11
|
+
* @returns an operator that initializes the pipe with a tap
|
|
10
12
|
*/
|
|
11
13
|
export declare function initialize<T>(tap: (value: Maybe<T>) => void, initial?: Maybe<T>, skipFirst?: boolean): MonoTypeOperatorFunction<T>;
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* Executes a side-effect on the first emission from the observable, then passes all values through.
|
|
14
16
|
*
|
|
15
|
-
* @param tap
|
|
16
|
-
* @param skipFirst
|
|
17
|
-
* @returns
|
|
17
|
+
* @param tap - the side-effect function to call once
|
|
18
|
+
* @param skipFirst - if true, skips the very first emission before tapping
|
|
19
|
+
* @returns an operator that taps the first value
|
|
18
20
|
*/
|
|
19
21
|
export declare function tapFirst<T>(tap: (value: T) => void, skipFirst?: boolean): MonoTypeOperatorFunction<T>;
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
23
|
+
* Wraps an observable so that it never emits `complete` until it is unsubscribed.
|
|
22
24
|
*
|
|
23
|
-
* The subscription will never have complete() called
|
|
24
|
-
*
|
|
25
|
+
* The subscription will never have `complete()` called since it only triggers after unsubscription.
|
|
26
|
+
* Use `finalize()` for additional cleanup.
|
|
25
27
|
*
|
|
26
|
-
* @param obs
|
|
27
|
-
* @returns
|
|
28
|
+
* @param obs - the source observable to wrap
|
|
29
|
+
* @returns an observable that only completes on unsubscription
|
|
28
30
|
*/
|
|
29
31
|
export declare function preventComplete<T>(obs: Observable<T>): Observable<T>;
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
33
|
+
* Creates a cold observable that defers execution of the getter until subscription, then shares the result.
|
|
34
|
+
*
|
|
35
|
+
* Unlike `from()`, the promise/observable is not created until the first subscriber connects.
|
|
32
36
|
*
|
|
33
|
-
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const data$ = lazyFrom(() => fetch('/api/data').then(r => r.json()));
|
|
40
|
+
* // The fetch is not called until data$ is subscribed to
|
|
41
|
+
* ```
|
|
34
42
|
*
|
|
35
|
-
* @param getter
|
|
36
|
-
* @returns
|
|
43
|
+
* @param getter - factory that returns a Promise or Observable
|
|
44
|
+
* @returns a shared observable that defers execution until subscription
|
|
37
45
|
*/
|
|
38
46
|
export declare function lazyFrom<T>(getter: Getter<Promise<T> | Observable<T>>): Observable<T>;
|
|
@@ -36,4 +36,21 @@ export interface ErrorOnEmissionsInPeriodConfig<T> {
|
|
|
36
36
|
*/
|
|
37
37
|
readonly errorMessage?: string;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* RxJS operator that throws an error (or switches to an alternative observable) when too many
|
|
41
|
+
* emissions occur within a rolling time period.
|
|
42
|
+
*
|
|
43
|
+
* Useful as a safety valve to detect infinite loops or runaway observables.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* source$.pipe(
|
|
48
|
+
* errorOnEmissionsInPeriod({ maxEmissionsPerPeriod: 100, period: 1000 })
|
|
49
|
+
* ).subscribe();
|
|
50
|
+
* // throws if more than 100 emissions occur within 1 second
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param config - period duration, max emissions, and error/fallback handling
|
|
54
|
+
* @returns an operator that monitors emission frequency
|
|
55
|
+
*/
|
|
39
56
|
export declare function errorOnEmissionsInPeriod<T>(config: ErrorOnEmissionsInPeriodConfig<T>): MonoTypeOperatorFunction<T>;
|
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
import { type Observable, type OperatorFunction } from 'rxjs';
|
|
2
2
|
import { type PrimativeKey, type ReadKeyFunction, type ReadMultipleKeysFunction } from '@dereekb/util';
|
|
3
3
|
/**
|
|
4
|
-
* Creates a
|
|
4
|
+
* Creates a function that takes a `Map` and combines the latest emissions from observables
|
|
5
|
+
* created from each map value.
|
|
5
6
|
*
|
|
6
|
-
* @param mapToObs
|
|
7
|
-
* @returns
|
|
7
|
+
* @param mapToObs - function to transform each map value into an observable
|
|
8
|
+
* @returns a function that converts a Map to a combined observable of results
|
|
8
9
|
*/
|
|
9
10
|
export declare function combineLatestFromMapValuesObsFn<T, O>(mapToObs: (value: T) => Observable<O>): (map: Map<unknown, T>) => Observable<O[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a function that takes an array of values, maps each to an observable, and combines their latest emissions.
|
|
13
|
+
*
|
|
14
|
+
* Returns `of([])` for empty arrays.
|
|
15
|
+
*
|
|
16
|
+
* @param mapToObs - function to transform each value into an observable
|
|
17
|
+
* @returns a function that converts an array to a combined observable
|
|
18
|
+
*/
|
|
10
19
|
export declare function combineLatestFromArrayObsFn<T, O>(mapToObs: (value: T) => Observable<O>): (values: T[]) => Observable<O[]>;
|
|
11
20
|
export type ObservableObjectMap = object;
|
|
12
21
|
export type ObservableObjectMapResult<T extends ObservableObjectMap> = {
|
|
13
22
|
[K in keyof T]: T[K] extends Observable<infer O> ? O : T[K];
|
|
14
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Combines the latest values from an object of observables into a single observable of resolved values.
|
|
26
|
+
*
|
|
27
|
+
* Each key in the input object maps to an observable (or static value). The result observable
|
|
28
|
+
* emits an object with the same keys, where each value is the latest emission from its source.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const result$ = combineLatestFromObject({
|
|
33
|
+
* name: of('Alice'),
|
|
34
|
+
* age: of(30)
|
|
35
|
+
* });
|
|
36
|
+
* // emits { name: 'Alice', age: 30 }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param objectMap - an object whose values are observables or static values
|
|
40
|
+
* @returns an observable that emits the resolved object
|
|
41
|
+
*/
|
|
15
42
|
export declare function combineLatestFromObject<T extends ObservableObjectMap>(objectMap: T): Observable<ObservableObjectMapResult<T>>;
|
|
16
43
|
/**
|
|
17
|
-
*
|
|
44
|
+
* RxJS operator that maps an array of items to a `Map<K, T>` using the provided key reader.
|
|
18
45
|
*
|
|
19
|
-
* @param read
|
|
20
|
-
* @returns
|
|
46
|
+
* @param read - function to extract the key from each item
|
|
47
|
+
* @returns an operator that converts an array into a keyed Map
|
|
21
48
|
*/
|
|
22
49
|
export declare function keyValueMap<T, K extends PrimativeKey = PrimativeKey>(read: ReadKeyFunction<T, K>): OperatorFunction<T[], Map<K, T>>;
|
|
23
50
|
/**
|
|
24
|
-
*
|
|
51
|
+
* RxJS operator that maps an array of items to a `Map<K, T>` using a multi-key reader,
|
|
52
|
+
* allowing each item to appear under multiple keys.
|
|
25
53
|
*
|
|
26
|
-
* @param read
|
|
27
|
-
* @returns
|
|
54
|
+
* @param read - function to extract multiple keys from each item
|
|
55
|
+
* @returns an operator that converts an array into a multi-keyed Map
|
|
28
56
|
*/
|
|
29
57
|
export declare function multiKeyValueMap<T, K extends PrimativeKey = PrimativeKey>(read: ReadMultipleKeysFunction<T, K>): OperatorFunction<T[], Map<K, T>>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type FilterUniqueFunctionAdditionalKeysInput, type PrimativeKey, type ReadKeyFunction } from '@dereekb/util';
|
|
2
2
|
import { type MonoTypeOperatorFunction } from 'rxjs';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* RxJS operator that filters an array to unique items based on a key reader function.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
6
|
+
* Uses {@link filterUniqueFunction} to deduplicate emitted arrays by extracting a key from each item.
|
|
7
|
+
*
|
|
8
|
+
* @param readKey - function to extract the unique key from each item
|
|
9
|
+
* @param additionalKeysInput - optional additional keys to include in the unique set
|
|
10
|
+
* @returns an operator that emits deduplicated arrays
|
|
8
11
|
*/
|
|
9
12
|
export declare function filterUnique<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>, additionalKeysInput?: FilterUniqueFunctionAdditionalKeysInput<T, K>): MonoTypeOperatorFunction<T[]>;
|
package/src/lib/rxjs/set.d.ts
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
import { type Maybe, type PrimativeKey, type ReadValueFunction, type EqualityComparatorFunction } from '@dereekb/util';
|
|
2
2
|
import { type MonoTypeOperatorFunction, type Observable, type OperatorFunction } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* RxJS operator that checks whether the emitted `Set` contains all values from the given observable.
|
|
5
|
+
*
|
|
6
|
+
* @param valuesObs - observable of values to check against
|
|
7
|
+
* @returns an operator that emits true if all values are contained in the set
|
|
8
|
+
*/
|
|
3
9
|
export declare function setContainsAllValuesFrom<T>(valuesObs: Observable<Maybe<Iterable<T>>>): OperatorFunction<Set<T>, boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* RxJS operator that checks whether the emitted `Set` contains any value from the given observable.
|
|
12
|
+
*
|
|
13
|
+
* @param valuesObs - observable of values to check against
|
|
14
|
+
* @returns an operator that emits true if any value is contained in the set
|
|
15
|
+
*/
|
|
4
16
|
export declare function setContainsAnyValueFrom<T>(valuesObs: Observable<Maybe<Iterable<T>>>): OperatorFunction<Set<T>, boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* RxJS operator that checks whether the emitted `Set` contains none of the values from the given observable.
|
|
19
|
+
*
|
|
20
|
+
* @param valuesObs - observable of values to check against
|
|
21
|
+
* @returns an operator that emits true if no values are contained in the set
|
|
22
|
+
*/
|
|
5
23
|
export declare function setContainsNoValueFrom<T>(valuesObs: Observable<Maybe<Iterable<T>>>): OperatorFunction<Set<T>, boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* `distinctUntilChanged` variant for iterables that only emits when the contained values change.
|
|
26
|
+
*/
|
|
6
27
|
export declare function distinctUntilHasDifferentValues<I extends Iterable<K>, K extends PrimativeKey>(): MonoTypeOperatorFunction<I>;
|
|
28
|
+
/**
|
|
29
|
+
* `distinctUntilChanged` variant that extracts iterable values from the emitted item and only emits
|
|
30
|
+
* when the set of extracted values changes.
|
|
31
|
+
*
|
|
32
|
+
* @param readValues - function to extract the iterable of values to compare
|
|
33
|
+
*/
|
|
7
34
|
export declare function distinctUntilItemsHaveDifferentValues<I, V extends Iterable<PrimativeKey>>(readValues: ReadValueFunction<I, V>): MonoTypeOperatorFunction<I>;
|
|
8
35
|
export declare function distinctUntilItemsHaveDifferentValues<I, V extends Iterable<PrimativeKey>>(readValues: ReadValueFunction<I, V>): MonoTypeOperatorFunction<Maybe<I>>;
|
|
36
|
+
/**
|
|
37
|
+
* `distinctUntilChanged` variant that extracts values from the emitted item and compares them
|
|
38
|
+
* using a custom equality comparator.
|
|
39
|
+
*
|
|
40
|
+
* @param readValues - function to extract the value to compare
|
|
41
|
+
* @param isEqualComparator - custom equality function for the extracted values
|
|
42
|
+
*/
|
|
9
43
|
export declare function distinctUntilItemsValueChanges<I, V>(readValues: ReadValueFunction<I, V>, isEqualComparator: EqualityComparatorFunction<V>): MonoTypeOperatorFunction<I>;
|
|
10
44
|
export declare function distinctUntilItemsValueChanges<I, V>(readValues: ReadValueFunction<I, V>, isEqualComparator: EqualityComparatorFunction<V>): MonoTypeOperatorFunction<Maybe<I>>;
|
package/src/lib/rxjs/string.d.ts
CHANGED
|
@@ -8,6 +8,23 @@ export interface SearchStringFilterConfig<T> {
|
|
|
8
8
|
readonly search$: Observable<Maybe<string>>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* RxJS operator that filters an emitted array by a reactive search string.
|
|
12
|
+
*
|
|
13
|
+
* Combines the source array with the `search$` observable and applies the configured
|
|
14
|
+
* search string filter function. When the search is null/undefined, all items pass through.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const items$ = of(['apple', 'banana', 'cherry']);
|
|
19
|
+
* const search$ = new BehaviorSubject<string>('an');
|
|
20
|
+
*
|
|
21
|
+
* items$.pipe(
|
|
22
|
+
* filterWithSearchString({ filter: (x) => x, search$ })
|
|
23
|
+
* ).subscribe(console.log);
|
|
24
|
+
* // ['banana']
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param config - search filter configuration with filter function and search$ observable
|
|
28
|
+
* @returns an operator that filters arrays by search string
|
|
12
29
|
*/
|
|
13
30
|
export declare function filterWithSearchString<T>(config: SearchStringFilterConfig<T>): MonoTypeOperatorFunction<T[]>;
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { type MonoTypeOperatorFunction } from 'rxjs';
|
|
2
2
|
import { type Getter, type GetterOrValue } from '@dereekb/util';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* RxJS operator that emits a default value if the source does not emit within the specified timeout.
|
|
5
|
+
*
|
|
6
|
+
* After the timeout, the default value is prepended and the source continues normally.
|
|
7
|
+
*
|
|
8
|
+
* @param defaultValue - value or getter to use as the default
|
|
9
|
+
* @param first - timeout in ms before emitting the default (defaults to 0)
|
|
10
|
+
* @returns an operator that provides a fallback on slow emissions
|
|
5
11
|
*/
|
|
6
12
|
export declare function timeoutStartWith<T>(defaultValue: GetterOrValue<T>, first?: number): MonoTypeOperatorFunction<T>;
|
|
13
|
+
/**
|
|
14
|
+
* RxJS operator that executes a side-effect function if the source does not emit within the given timeout.
|
|
15
|
+
*
|
|
16
|
+
* @param timeoutDelay - timeout in ms before triggering the side-effect
|
|
17
|
+
* @param useFn - side-effect function to call on timeout
|
|
18
|
+
* @returns an operator that taps after timeout
|
|
19
|
+
*/
|
|
7
20
|
export declare function tapAfterTimeout<T>(timeoutDelay: number, useFn: () => void): MonoTypeOperatorFunction<T>;
|
|
21
|
+
/**
|
|
22
|
+
* RxJS operator that throws an error if the source does not emit within the given timeout.
|
|
23
|
+
*
|
|
24
|
+
* @param timeoutDelay - timeout in ms before throwing
|
|
25
|
+
* @param error - getter that produces the error to throw
|
|
26
|
+
* @returns an operator that throws on timeout
|
|
27
|
+
*/
|
|
8
28
|
export declare function throwErrorAfterTimeout<T>(timeoutDelay: number, error: Getter<unknown>): MonoTypeOperatorFunction<T>;
|
package/src/lib/rxjs/use.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Subscribes to the observable, calls the provided function with the first emitted value,
|
|
4
|
+
* then automatically unsubscribes.
|
|
4
5
|
*
|
|
5
|
-
* @param
|
|
6
|
+
* @param obs - the source observable
|
|
7
|
+
* @param useFn - function to call with the first value
|
|
6
8
|
*/
|
|
7
9
|
export declare function useFirst<T>(obs: Observable<T>, useFn: (value: T) => void): void;
|