expect(runner.effect.fn).toBe(otherRunner.effect.fn)
})
+ it('should wrap if the passed function is a fake effect', () => {
+ const fakeRunner = () => {}
+ fakeRunner.effect = {}
+ const runner = effect(fakeRunner)
+ expect(fakeRunner).not.toBe(runner)
+ expect(runner.effect.fn).toBe(fakeRunner)
+ })
+
it('should not run multiple times for a single mutation', () => {
let dummy
const obj = reactive<Record<string, number>>({})
// which maintains a Set of subscribers, but we simply store them as
// raw Sets to reduce memory overhead.
type KeyToDepMap = Map<any, Dep>
-const targetMap = new WeakMap<any, KeyToDepMap>()
+const targetMap = new WeakMap<object, KeyToDepMap>()
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0
fn: () => T,
options?: ReactiveEffectOptions
): ReactiveEffectRunner {
- if ((fn as ReactiveEffectRunner).effect) {
+ if ((fn as ReactiveEffectRunner).effect instanceof ReactiveEffect) {
fn = (fn as ReactiveEffectRunner).effect.fn
}