File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,14 @@ describe('reactivity/effect', () => {
585585 expect ( runner . effect . fn ) . toBe ( otherRunner . effect . fn )
586586 } )
587587
588+ it ( 'should wrap if the passed function is a fake effect' , ( ) => {
589+ const fakeRunner = ( ) => { }
590+ fakeRunner . effect = { }
591+ const runner = effect ( fakeRunner )
592+ expect ( fakeRunner ) . not . toBe ( runner )
593+ expect ( runner . effect . fn ) . toBe ( fakeRunner )
594+ } )
595+
588596 it ( 'should not run multiple times for a single mutation' , ( ) => {
589597 let dummy
590598 const obj = reactive < Record < string , number > > ( { } )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import { ComputedRefImpl } from './computed'
1616// which maintains a Set of subscribers, but we simply store them as
1717// raw Sets to reduce memory overhead.
1818type KeyToDepMap = Map < any , Dep >
19- const targetMap = new WeakMap < any , KeyToDepMap > ( )
19+ const targetMap = new WeakMap < object , KeyToDepMap > ( )
2020
2121// The number of effects currently being tracked recursively.
2222let effectTrackDepth = 0
@@ -181,7 +181,7 @@ export function effect<T = any>(
181181 fn : ( ) => T ,
182182 options ?: ReactiveEffectOptions
183183) : ReactiveEffectRunner {
184- if ( ( fn as ReactiveEffectRunner ) . effect ) {
184+ if ( ( fn as ReactiveEffectRunner ) . effect instanceof ReactiveEffect ) {
185185 fn = ( fn as ReactiveEffectRunner ) . effect . fn
186186 }
187187
You can’t perform that action at this time.
0 commit comments