@@ -3,13 +3,14 @@ import { qwikDebugToString } from '../../debug';
3
3
import type { Container } from '../../shared/types' ;
4
4
import { ChoreType } from '../../shared/util-chore-type' ;
5
5
import { isPromise } from '../../shared/utils/promises' ;
6
- import { trackFn } from '../../use/utils/tracker' ;
6
+ import { cleanupFn , trackFn } from '../../use/utils/tracker' ;
7
7
import type { BackRef } from '../cleanup' ;
8
8
import type { AsyncComputeQRL , EffectSubscription } from '../types' ;
9
9
import { _EFFECT_BACK_REF , EffectProperty , SignalFlags } from '../types' ;
10
10
import { throwIfQRLNotResolved } from '../utils' ;
11
11
import { ComputedSignalImpl } from './computed-signal-impl' ;
12
12
import { setupSignalValueAccess } from './signal-impl' ;
13
+ import type { NoSerialize } from '../../shared/utils/serialize-utils' ;
13
14
14
15
const DEBUG = false ;
15
16
const log = ( ...args : any [ ] ) =>
@@ -32,6 +33,7 @@ export class AsyncComputedSignalImpl<T>
32
33
33
34
$pendingEffects$ : null | Set < EffectSubscription > = null ;
34
35
$failedEffects$ : null | Set < EffectSubscription > = null ;
36
+ $destroy$ : NoSerialize < ( ) => void > | null ;
35
37
private $promiseValue$ : T | null = null ;
36
38
37
39
[ _EFFECT_BACK_REF ] : Map < EffectProperty | string , EffectSubscription > | null = null ;
@@ -103,8 +105,13 @@ export class AsyncComputedSignalImpl<T>
103
105
const computeQrl = this . $computeQrl$ ;
104
106
throwIfQRLNotResolved ( computeQrl ) ;
105
107
108
+ const [ cleanup ] = cleanupFn ( this , ( err ) => this . $container$ ?. handleError ( err , null ! ) ) ;
106
109
const untrackedValue =
107
- this . $promiseValue$ ?? ( computeQrl . getFn ( ) ( { track : trackFn ( this , this . $container$ ) } ) as T ) ;
110
+ this . $promiseValue$ ??
111
+ ( computeQrl . getFn ( ) ( {
112
+ track : trackFn ( this , this . $container$ ) ,
113
+ cleanup,
114
+ } ) as T ) ;
108
115
if ( isPromise ( untrackedValue ) ) {
109
116
this . untrackedPending = true ;
110
117
this . untrackedFailed = false ;
0 commit comments