File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,14 @@ describe('reactivity/effect', () => {
585
585
expect ( runner . effect . fn ) . toBe ( otherRunner . effect . fn )
586
586
} )
587
587
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
+
588
596
it ( 'should not run multiple times for a single mutation' , ( ) => {
589
597
let dummy
590
598
const obj = reactive < Record < string , number > > ( { } )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import { ComputedRefImpl } from './computed'
16
16
// which maintains a Set of subscribers, but we simply store them as
17
17
// raw Sets to reduce memory overhead.
18
18
type KeyToDepMap = Map < any , Dep >
19
- const targetMap = new WeakMap < any , KeyToDepMap > ( )
19
+ const targetMap = new WeakMap < object , KeyToDepMap > ( )
20
20
21
21
// The number of effects currently being tracked recursively.
22
22
let effectTrackDepth = 0
@@ -181,7 +181,7 @@ export function effect<T = any>(
181
181
fn : ( ) => T ,
182
182
options ?: ReactiveEffectOptions
183
183
) : ReactiveEffectRunner {
184
- if ( ( fn as ReactiveEffectRunner ) . effect ) {
184
+ if ( ( fn as ReactiveEffectRunner ) . effect instanceof ReactiveEffect ) {
185
185
fn = ( fn as ReactiveEffectRunner ) . effect . fn
186
186
}
187
187
You can’t perform that action at this time.
0 commit comments