|
1 |
| -import { Observable, ObservedValueOf, of, OperatorFunction, pipe } from 'rxjs'; |
| 1 | +import { Observable, ObservableInput, of, ObservedValueOf, OperatorFunction } from 'rxjs'; |
2 | 2 | import { concatMap, withLatestFrom } from 'rxjs/operators';
|
3 | 3 |
|
4 | 4 | // The array overload is needed first because we want to maintain the proper order in the resulting tuple
|
@@ -38,24 +38,22 @@ export function concatLatestFrom<T extends Observable<unknown>, V>(
|
38 | 38 | * ```
|
39 | 39 | */
|
40 | 40 | export function concatLatestFrom<
|
41 |
| - T extends Observable<unknown>[] | Observable<unknown>, |
| 41 | + T extends ObservableInput<unknown>[] | ObservableInput<unknown>, |
42 | 42 | V,
|
43 | 43 | R = [
|
44 | 44 | V,
|
45 |
| - ...(T extends Observable<unknown>[] |
| 45 | + ...(T extends ObservableInput<unknown>[] |
46 | 46 | ? { [i in keyof T]: ObservedValueOf<T[i]> }
|
47 | 47 | : [ObservedValueOf<T>])
|
48 | 48 | ]
|
49 | 49 | >(observablesFactory: (value: V) => T): OperatorFunction<V, R> {
|
50 |
| - return pipe( |
51 |
| - concatMap((value) => { |
52 |
| - const observables = observablesFactory(value); |
53 |
| - const observablesAsArray = Array.isArray(observables) |
54 |
| - ? observables |
55 |
| - : [observables]; |
56 |
| - return of(value).pipe( |
57 |
| - withLatestFrom(...observablesAsArray) |
58 |
| - ) as unknown as Observable<R>; |
59 |
| - }) |
60 |
| - ); |
| 50 | + return concatMap((value) => { |
| 51 | + const observables = observablesFactory(value); |
| 52 | + const observablesAsArray = Array.isArray(observables) |
| 53 | + ? observables |
| 54 | + : [observables]; |
| 55 | + return of(value).pipe( |
| 56 | + withLatestFrom(...observablesAsArray) |
| 57 | + ) as unknown as Observable<R>; |
| 58 | + }) |
61 | 59 | }
|
0 commit comments