@@ -287,6 +287,8 @@ class CustomRefImpl<T> {
287
287
288
288
public readonly [ ReactiveFlags . IS_REF ] = true
289
289
290
+ public _value : T = undefined !
291
+
290
292
constructor ( factory : CustomRefFactory < T > ) {
291
293
const dep = ( this . dep = new Dep ( ) )
292
294
const { get, set } = factory ( dep . track . bind ( dep ) , dep . trigger . bind ( dep ) )
@@ -295,7 +297,7 @@ class CustomRefImpl<T> {
295
297
}
296
298
297
299
get value ( ) {
298
- return this . _get ( )
300
+ return ( this . _value = this . _get ( ) )
299
301
}
300
302
301
303
set value ( newVal ) {
@@ -339,6 +341,7 @@ export function toRefs<T extends object>(object: T): ToRefs<T> {
339
341
340
342
class ObjectRefImpl < T extends object , K extends keyof T > {
341
343
public readonly [ ReactiveFlags . IS_REF ] = true
344
+ public _value : T [ K ] = undefined !
342
345
343
346
constructor (
344
347
private readonly _object : T ,
@@ -348,7 +351,7 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
348
351
349
352
get value ( ) {
350
353
const val = this . _object [ this . _key ]
351
- return val === undefined ? this . _defaultValue ! : val
354
+ return ( this . _value = val === undefined ? this . _defaultValue ! : val )
352
355
}
353
356
354
357
set value ( newVal ) {
@@ -363,9 +366,11 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
363
366
class GetterRefImpl < T > {
364
367
public readonly [ ReactiveFlags . IS_REF ] = true
365
368
public readonly [ ReactiveFlags . IS_READONLY ] = true
369
+ public _value : T = undefined !
370
+
366
371
constructor ( private readonly _getter : ( ) => T ) { }
367
372
get value ( ) {
368
- return this . _getter ( )
373
+ return ( this . _value = this . _getter ( ) )
369
374
}
370
375
}
371
376
0 commit comments