File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -43,21 +43,24 @@ export class Signal<T = any> {
43
43
}
44
44
45
45
peek ( ) {
46
- if ( currentSignal && currentSignal . _canActivate && this . _deps . size === 0 ) {
46
+ const shouldActivate = ! currentSignal || currentSignal . _canActivate ;
47
+ if ( shouldActivate && this . _deps . size === 0 ) {
47
48
activate ( this ) ;
48
49
}
49
50
return this . _value ;
50
51
}
51
52
52
53
get value ( ) {
53
- if ( ! currentSignal ) {
54
- return this . _value ;
54
+ const shouldActivate = ! currentSignal || currentSignal . _canActivate ;
55
+ if ( shouldActivate && this . _deps . size === 0 ) {
56
+ activate ( this ) ;
55
57
}
58
+
56
59
// If we read a signal outside of a computed we have no way
57
60
// to unsubscribe from that. So we assume that the user wants
58
61
// to get the value immediately like for testing.
59
- if ( currentSignal . _canActivate && this . _deps . size === 0 ) {
60
- activate ( this ) ;
62
+ if ( ! currentSignal ) {
63
+ return this . _value ;
61
64
}
62
65
63
66
// subscribe the current computed to this signal:
You can’t perform that action at this time.
0 commit comments