You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When extensively using combineLatest or forkJoin, especially with many arguments, it can be cumbersome to have the result as an array (e.g. you can't pluck) and I typically end up having a single:
map(([a,b,c]) => ({a,b,c}))
Except it can be with many arguments and their names are obviously longer.
Moreover, the result of a combineLatest(a,b,c) (with 7+ arguments) is a [typeof(a)|typeof(b)|typeof(c)], which is not very type-safe, e.g.:
combineLatest([
of(true),
of('hello world'),
of(42)
]).pipe(
map(([a, b, c]) => {
// a is boolean|string|number
// b is boolean|string|number
// c is boolean|string|number
})
);
Describe the solution you'd like
On top of taking an array, combineLatest and forkJoin could take an object where each field is an Observable. It would then return an object with what the observable emitted, e.g:
combineLatest({
a: of(true),
b: of('hello world'),
c: of(42)
}).pipe(
map(({a, b, c}) => ({
// a is boolean
// b is string
// c is number
})
);
Describe alternatives you've considered
Writing a pipable operator, however due to TypeScript limitations there is not much that can be done to turn the array into an object, especially after combineLatest and forkJoin already lost most of the type information for each array element.
The text was updated successfully, but these errors were encountered:
Feature Request
Is your feature request related to a problem? Please describe.
When extensively using
combineLatest
orforkJoin
, especially with many arguments, it can be cumbersome to have the result as an array (e.g. you can'tpluck
) and I typically end up having a single:Except it can be with many arguments and their names are obviously longer.
Moreover, the result of a
combineLatest(a,b,c)
(with 7+ arguments) is a[typeof(a)|typeof(b)|typeof(c)]
, which is not very type-safe, e.g.:Describe the solution you'd like
On top of taking an array,
combineLatest
andforkJoin
could take an object where each field is anObservable
. It would then return an object with what the observable emitted, e.g:Describe alternatives you've considered
Writing a pipable operator, however due to TypeScript limitations there is not much that can be done to turn the array into an object, especially after
combineLatest
andforkJoin
already lost most of the type information for each array element.The text was updated successfully, but these errors were encountered: