Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trackEffects()方法,会有‘循环引用’ (不知道这个词是否恰当)吗? #117

Open
TomLongJoy opened this issue Apr 11, 2024 · 2 comments

Comments

@TomLongJoy
Copy link

image
export function trackEffects(dep) {
//看看 dep 之前有没有添加过,添加过的话 那么就不添加了
if (dep.has(activeEffect)) return;
dep.add(activeEffect)
activeEffect.deps.push(dep); // 反向搜集

// start --- test 
let count = 0;
if( activeEffect.deps.length ){
    testMethod(activeEffect);
}
function testMethod(activeEffect){
    const dep = activeEffect.deps[0]
    for (const effect of dep) {            // debugger
        count++;
        if(count > 1000){
            debugger
            console.log('循环结束')
            return;
        }
        testMethod(effect);
        
    }
}
// end -- test 

}

@viacooter
Copy link

viacooter commented Apr 11, 2024 via email

@TomLongJoy
Copy link
Author

fa793a17ca9cc4a160f8c8ac6f20d5e
这个di'f地方是不是得用WeakMap()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants