Skip to content

Commit 34dd28c

Browse files
authored
feat(effects): accept ObservableInput as concatLatestFrom argument (#3838)
1 parent dc78447 commit 34dd28c

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

modules/effects/src/concat_latest_from.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Observable, ObservedValueOf, of, OperatorFunction, pipe } from 'rxjs';
1+
import { Observable, ObservableInput, of, ObservedValueOf, OperatorFunction } from 'rxjs';
22
import { concatMap, withLatestFrom } from 'rxjs/operators';
33

44
// 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>(
3838
* ```
3939
*/
4040
export function concatLatestFrom<
41-
T extends Observable<unknown>[] | Observable<unknown>,
41+
T extends ObservableInput<unknown>[] | ObservableInput<unknown>,
4242
V,
4343
R = [
4444
V,
45-
...(T extends Observable<unknown>[]
45+
...(T extends ObservableInput<unknown>[]
4646
? { [i in keyof T]: ObservedValueOf<T[i]> }
4747
: [ObservedValueOf<T>])
4848
]
4949
>(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+
})
6159
}

0 commit comments

Comments
 (0)