@@ -4,7 +4,7 @@ import { distinctUntilChanged, filter, map, shareReplay } from 'rxjs/operators';
4
4
import { Promise } from '@rx-angular/cdk/zone-less/browser' ;
5
5
import { coalesceWith } from '@rx-angular/cdk/coalescing' ;
6
6
import { ExtractObservableValue } from '../../../../cdk/internals/core/src/lib/model' ;
7
- import { NonUndefined , NotEmpty , ObservableMap } from './interfaces' ;
7
+ import { NotEmpty , ObservableMap } from './interfaces' ;
8
8
import { coerceObservable } from '@rx-angular/cdk/coercing' ;
9
9
10
10
const resolvedPromise = Promise . resolve ( ) ;
@@ -72,9 +72,7 @@ export function smosh<T extends ObservableMap | (Partial<T> & NotEmpty<T>), U ex
72
72
obj [ keys [ i ] ] = values [ i ] ;
73
73
}
74
74
return obj ;
75
- } ) ,
76
- // by using shareReplay we share the last composition work done to create the accumulated object
77
- shareReplay ( 1 )
75
+ } )
78
76
)
79
77
spreads = spreads . map ( o => o . pipe (
80
78
// we avoid using the nullish operator later ;)
@@ -83,8 +81,17 @@ export function smosh<T extends ObservableMap | (Partial<T> & NotEmpty<T>), U ex
83
81
distinctUntilChanged ( )
84
82
)
85
83
) ;
86
- return merge ( ...spreads , obj$ ) . pipe ( scan ( ( acc , slice ) => ( { ...acc , ...slice } ) , { } ) ) . pipe (
84
+
85
+ return merge ( ...spreads , obj$ ) . pipe ( scan ( ( acc , slice ) => {
86
+ const ks = Object . keys ( slice ) as ( keyof T ) [ ] ;
87
+ for ( let i = 0 ; i < ks . length ; i ++ ) {
88
+ acc [ ks [ i ] as any ] = slice [ ks [ i ] ] ;
89
+ }
90
+ return acc as any ;
91
+ } , { } ) ) . pipe (
87
92
// As combineLatest will emit multiple times for a change in multiple properties we coalesce those emissions together
88
- coalesceWith ( durationSelector )
93
+ coalesceWith ( durationSelector ) ,
94
+ // by using shareReplay we share the last composition work done to create the accumulated object
95
+ shareReplay ( 1 )
89
96
) ;
90
97
}
0 commit comments