File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -537,19 +537,21 @@ declare class Computed<T = any> extends Signal<T> {
537
537
_globalVersion : number ;
538
538
_flags : number ;
539
539
540
- constructor ( fn : ( ) => T ) ;
540
+ constructor ( fn : ( ) => T , options ?: SignalOptions < T > ) ;
541
541
542
542
_notify ( ) : void ;
543
543
get value ( ) : T ;
544
544
}
545
545
546
- function Computed ( this : Computed , fn : ( ) => unknown ) {
546
+ function Computed ( this : Computed , fn : ( ) => unknown , options ?: SignalOptions ) {
547
547
Signal . call ( this , undefined ) ;
548
548
549
549
this . _fn = fn ;
550
550
this . _sources = undefined ;
551
551
this . _globalVersion = globalVersion - 1 ;
552
552
this . _flags = OUTDATED ;
553
+ this . _watched = options ?. watched ;
554
+ this . _unwatched = options ?. unwatched ;
553
555
}
554
556
555
557
Computed . prototype = new Signal ( ) as Computed ;
@@ -626,9 +628,8 @@ Computed.prototype._subscribe = function (node) {
626
628
627
629
Computed . prototype . _unsubscribe = function ( node ) {
628
630
// Only run the unsubscribe step if the computed signal has any subscribers.
631
+ Signal . prototype . _unsubscribe . call ( this , node ) ;
629
632
if ( this . _targets !== undefined ) {
630
- Signal . prototype . _unsubscribe . call ( this , node ) ;
631
-
632
633
// Computed signal unsubscribes from its dependencies when it loses its last subscriber.
633
634
// This makes it possible for unreferences subgraphs of computed signals to get garbage collected.
634
635
if ( this . _targets === undefined ) {
You can’t perform that action at this time.
0 commit comments