File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ describe('signalState', () => {
59
59
expect ( ( state . user . firstName as any ) . y ) . toBe ( undefined ) ;
60
60
} ) ;
61
61
62
+ it ( 'does not modify STATE_SIGNAL' , ( ) => {
63
+ const state = signalState ( initialState ) ;
64
+
65
+ expect ( ( state [ STATE_SIGNAL ] as any ) . user ) . toBe ( undefined ) ;
66
+ expect ( ( state [ STATE_SIGNAL ] as any ) . foo ) . toBe ( undefined ) ;
67
+ expect ( ( state [ STATE_SIGNAL ] as any ) . numbers ) . toBe ( undefined ) ;
68
+ expect ( ( state [ STATE_SIGNAL ] as any ) . ngrx ) . toBe ( undefined ) ;
69
+ } ) ;
70
+
62
71
it (
63
72
'emits new values only for affected signals' ,
64
73
testEffects ( ( tick ) => {
Original file line number Diff line number Diff line change 1
- import { isSignal , Signal , untracked } from '@angular/core' ;
1
+ import { Signal , untracked } from '@angular/core' ;
2
2
import { selectSignal } from './select-signal' ;
3
3
4
4
export type DeepSignal < T > = Signal < T > &
@@ -14,11 +14,15 @@ export function toDeepSignal<T>(signal: Signal<T>): DeepSignal<T> {
14
14
15
15
return new Proxy ( signal , {
16
16
get ( target : any , prop ) {
17
- if ( prop in value && ! target [ prop ] ) {
17
+ if ( ! ( prop in value ) ) {
18
+ return target [ prop ] ;
19
+ }
20
+
21
+ if ( ! target [ prop ] ) {
18
22
target [ prop ] = selectSignal ( ( ) => target ( ) [ prop ] ) ;
19
23
}
20
24
21
- return isSignal ( target [ prop ] ) ? toDeepSignal ( target [ prop ] ) : target [ prop ] ;
25
+ return toDeepSignal ( target [ prop ] ) ;
22
26
} ,
23
27
} ) ;
24
28
}
You can’t perform that action at this time.
0 commit comments